Talk:Key Compression
Revision as of 03:10, 5 February 2015 by Pedro Oval (talk | contribs) (oops, how did that get there?)
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")));
}