Difference between revisions of "XORKey"

From Second Life Wiki
Jump to navigation Jump to search
m (tweaked)
m (<lsl> tag to <source>)
 
Line 12: Line 12:
* LSO: 528 bytes
* LSO: 528 bytes
* MONO: 2048 bytes
* MONO: 2048 bytes
<lsl>key uXORKey( string vStrOne, string vStrTwo ){
<source lang="lsl2">key uXORKey( string vStrOne, string vStrTwo ){
     vStrOne = (string)llParseString2List( vStrOne, ["-"], [] );
     vStrOne = (string)llParseString2List( vStrOne, ["-"], [] );
     vStrTwo = (string)llParseString2List( vStrTwo, ["-"], [] );
     vStrTwo = (string)llParseString2List( vStrTwo, ["-"], [] );
Line 35: Line 35:
/*//  2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]  //*/
/*//  2009 (CC0) [ http://creativecommons.org/publicdomain/zero/1.0 ]  //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//  Void Singer [ https://wiki.secondlife.com/wiki/User:Void_Singer ]  //*/
/*//--                                                                --//*/</lsl><!-- Please do not remove license statement -->
/*//--                                                                --//*/</source><!-- Please do not remove license statement -->
}}
}}



Latest revision as of 14:50, 22 January 2015

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
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 ]  //*/
/*//--                                                                 --//*/

Caveats

  • This function does not check input key validity