XORKey

From Second Life Wiki
Revision as of 12:07, 12 October 2010 by Void Singer (talk | contribs) (more free code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

User-Defined Function: key uXORKey( string vStrOne, string vStrTwo );

Returns a key that is vStrOne bitwise XOR'd with vStrTwo.

  • vStrOne: source key
  • vStrTwo: source key


Simple Code:

  • LSO: 528 bytes
  • MONO: 2048 bytes

<lsl>key uXORKey( string vStrOne, string vStrTwo ){

   vStrOne = (string)llParseString2List( vStrOne, ["-"], [] );
   vStrTwo = (string)llParseString2List( vStrTwo, ["-"], [] );
   string  vStrHex = "0123456789abcdef";
   integer vIdxXOR = 0xFFFFFFE0; //-- (-32)
   integer vIdxChr;
   do{
       vStrTwo += 
         llGetSubString( vStrHex,
                         vIdxChr = (integer)("0x" + llGetSubString( vStrOne, vIdxXOR, vIdxXOR )) ^
                                   (integer)("0x" + llGetSubString( vStrTwo, vIdxXOR, vIdxXOR )),
                         vIdxChr );
   }while (++vIdxXOR);
   return
     (key)(llGetSubString( vStrTwo, 0xFFFFFFE0, 0xFFFFFFE7 ) + //-- (-32, -25)
     "-" + llGetSubString( vStrTwo, 0xFFFFFFE8, 0xFFFFFFEB ) + //-- (-24, -21)
     "-" + llGetSubString( vStrTwo, 0xFFFFFFEC, 0xFFFFFFEF ) + //-- (-20, -17)
     "-" + llGetSubString( vStrTwo, 0xFFFFFFF0, 0xFFFFFFF3 ) + //-- (-16, -13)
     "-" + llGetSubString( vStrTwo, 0xFFFFFFF4, 0xFFFFFFFF )); //-- (-12, -1)

} /*//-- Anti-License Text --//*/ /*// Contributed Freely to the Public Domain without limitation. //*/ /*// 2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ] //*/ /*// Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ] //*/

/*//-- --//*/</lsl>

Caveats

  • This function does not check input key validity