Difference between revisions of "Talk:Key Compression"
Jump to navigation
Jump to search
Pedro Oval (talk | contribs) m (<lsl> to <source>) |
Pedro Oval (talk | contribs) m (oops, how did that get there?) |
||
Line 41: | Line 41: | ||
integer2hex(llBase64ToInteger(llGetSubString(s,16,19))) + | integer2hex(llBase64ToInteger(llGetSubString(s,16,19))) + | ||
integer2hex(llBase64ToInteger(llGetSubString(s,20,21)+"AA"))); | integer2hex(llBase64ToInteger(llGetSubString(s,20,21)+"AA"))); | ||
}</source | }</source> |
Revision as of 03:10, 5 February 2015
Recommending the following for base64 example for compatibility:
string keyToBase64(string s) {
s = llDumpList2String(llParseString2List(s, ["-"], []), "");
return
llGetSubString(llIntegerToBase64((integer)("0x"+llGetSubString(s,0,5))<<8),0,3) +
llGetSubString(llIntegerToBase64((integer)("0x"+llGetSubString(s,6,11))<<8),0,3) +
llGetSubString(llIntegerToBase64((integer)("0x"+llGetSubString(s,12,17))<<8),0,3) +
llGetSubString(llIntegerToBase64((integer)("0x"+llGetSubString(s,18,23))<<8),0,3) +
llGetSubString(llIntegerToBase64((integer)("0x"+llGetSubString(s,24,29))<<8),0,3) +
llGetSubString(llIntegerToBase64((integer)("0x"+llGetSubString(s,30,31))<<24),0,1);
}
string integer2hex(integer in) {
string s = "0123456789abcdef";
string ret = "";
integer i;
in = in >> 8;
for (i = 0; i < 6; i++) {
ret = llGetSubString(s, in & 0xF, in & 0xF) + ret;
in = in >> 4;
}
return ret;
}
string pad_dash(string s) {
return
llGetSubString(s, 0, 7) + "-" +
llGetSubString(s, 8,11) + "-" +
llGetSubString(s,12,15) + "-" +
llGetSubString(s,16,19) + "-" +
llGetSubString(s,20,31);
}
key base64ToKey(string s) {
return (key) pad_dash(
integer2hex(llBase64ToInteger(llGetSubString(s,0,3))) +
integer2hex(llBase64ToInteger(llGetSubString(s,4,7))) +
integer2hex(llBase64ToInteger(llGetSubString(s,8,11))) +
integer2hex(llBase64ToInteger(llGetSubString(s,12,15))) +
integer2hex(llBase64ToInteger(llGetSubString(s,16,19))) +
integer2hex(llBase64ToInteger(llGetSubString(s,20,21)+"AA")));
}