Difference between revisions of "XORKey"

From Second Life Wiki
Jump to navigation Jump to search
(more free code)
 
m (tweaked)
Line 16: Line 16:
     vStrTwo = (string)llParseString2List( vStrTwo, ["-"], [] );
     vStrTwo = (string)llParseString2List( vStrTwo, ["-"], [] );
     string  vStrHex = "0123456789abcdef";
     string  vStrHex = "0123456789abcdef";
     integer vIdxXOR = 0xFFFFFFE0; //-- (-32)
     integer vIdxChr 0xFFFFFFE0; //-- (-32)
     integer vIdxChr;
     integer vIdxHex;
     do{
     do{
         vStrTwo +=  
         vStrHex += llGetSubString( vStrHex,
          llGetSubString( vStrHex,
                                  vIdxHex = (integer)("0x" + llGetSubString( vStrOne, vIdxChr, vIdxChr )) ^
                          vIdxChr = (integer)("0x" + llGetSubString( vStrOne, vIdxXOR, vIdxXOR )) ^
                                            (integer)("0x" + llGetSubString( vStrTwo, vIdxChr, vIdxChr )),
                                    (integer)("0x" + llGetSubString( vStrTwo, vIdxXOR, vIdxXOR )),
                                  vIdxHex );
                          vIdxChr );
     }while (++vIdxChr);
     }while (++vIdxXOR);
     return
     return
       (key)(llGetSubString( vStrTwo, 0xFFFFFFE0, 0xFFFFFFE7 ) + //-- (-32, -25)
       (key)(llGetSubString( vStrHex, 0xFFFFFFE0, 0xFFFFFFE7 ) + //-- (-32, -25)
       "-" + llGetSubString( vStrTwo, 0xFFFFFFE8, 0xFFFFFFEB ) + //-- (-24, -21)
       "-" + llGetSubString( vStrHex, 0xFFFFFFE8, 0xFFFFFFEB ) + //-- (-24, -21)
       "-" + llGetSubString( vStrTwo, 0xFFFFFFEC, 0xFFFFFFEF ) + //-- (-20, -17)
       "-" + llGetSubString( vStrHex, 0xFFFFFFEC, 0xFFFFFFEF ) + //-- (-20, -17)
       "-" + llGetSubString( vStrTwo, 0xFFFFFFF0, 0xFFFFFFF3 ) + //-- (-16, -13)
       "-" + llGetSubString( vStrHex, 0xFFFFFFF0, 0xFFFFFFF3 ) + //-- (-16, -13)
       "-" + llGetSubString( vStrTwo, 0xFFFFFFF4, 0xFFFFFFFF )); //-- (-12, -1)
       "-" + llGetSubString( vStrHex, 0xFFFFFFF4, 0xFFFFFFFF )); //-- (-12, -1)
}
}
/*//--                      Anti-License Text                        --//*/
/*//--                      Anti-License Text                        --//*/

Revision as of 02:05, 13 October 2010

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