XORKey

From Second Life Wiki
Revision as of 02:05, 13 October 2010 by Void Singer (talk | contribs) (tweaked)
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 vIdxChr 0xFFFFFFE0; //-- (-32)
   integer vIdxHex;
   do{
       vStrHex += llGetSubString( vStrHex,
                                  vIdxHex = (integer)("0x" + llGetSubString( vStrOne, vIdxChr, vIdxChr )) ^
                                            (integer)("0x" + llGetSubString( vStrTwo, vIdxChr, vIdxChr )),
                                  vIdxHex );
   }while (++vIdxChr);
   return
     (key)(llGetSubString( vStrHex, 0xFFFFFFE0, 0xFFFFFFE7 ) + //-- (-32, -25)
     "-" + llGetSubString( vStrHex, 0xFFFFFFE8, 0xFFFFFFEB ) + //-- (-24, -21)
     "-" + llGetSubString( vStrHex, 0xFFFFFFEC, 0xFFFFFFEF ) + //-- (-20, -17)
     "-" + llGetSubString( vStrHex, 0xFFFFFFF0, 0xFFFFFFF3 ) + //-- (-16, -13)
     "-" + llGetSubString( vStrHex, 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