Difference between revisions of "XORKey"
Jump to navigation
Jump to search
Void Singer (talk | contribs) (more free code) |
Void Singer (talk | contribs) m (tweaked) |
||
Line 16: | Line 16: | ||
vStrTwo = (string)llParseString2List( vStrTwo, ["-"], [] ); | vStrTwo = (string)llParseString2List( vStrTwo, ["-"], [] ); | ||
string vStrHex = "0123456789abcdef"; | string vStrHex = "0123456789abcdef"; | ||
integer | integer vIdxChr 0xFFFFFFE0; //-- (-32) | ||
integer | integer vIdxHex; | ||
do{ | do{ | ||
vStrHex += llGetSubString( vStrHex, | |||
vIdxHex = (integer)("0x" + llGetSubString( vStrOne, vIdxChr, vIdxChr )) ^ | |||
(integer)("0x" + llGetSubString( vStrTwo, vIdxChr, vIdxChr )), | |||
vIdxHex ); | |||
}while (++vIdxChr); | |||
}while (++ | |||
return | return | ||
(key)(llGetSubString( | (key)(llGetSubString( vStrHex, 0xFFFFFFE0, 0xFFFFFFE7 ) + //-- (-32, -25) | ||
"-" + llGetSubString( | "-" + llGetSubString( vStrHex, 0xFFFFFFE8, 0xFFFFFFEB ) + //-- (-24, -21) | ||
"-" + llGetSubString( | "-" + llGetSubString( vStrHex, 0xFFFFFFEC, 0xFFFFFFEF ) + //-- (-20, -17) | ||
"-" + llGetSubString( | "-" + llGetSubString( vStrHex, 0xFFFFFFF0, 0xFFFFFFF3 ) + //-- (-16, -13) | ||
"-" + llGetSubString( | "-" + llGetSubString( vStrHex, 0xFFFFFFF4, 0xFFFFFFFF )); //-- (-12, -1) | ||
} | } | ||
/*//-- Anti-License Text --//*/ | /*//-- Anti-License Text --//*/ |
Revision as of 02:05, 13 October 2010
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials | User-Defined Functions | Void's User Page |
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