CODE
// Get the Adler32 CRC (i.e. hash value) of a string of characters.
// Adapted from code found at php.net/crc32 and released into the public domain by Huns Valen.
// It is not as reliable as a full CRC32, but it does run faster!
string ASCIndex;
initAsc() {
// This is Xylor's char array from XyText
ASCIndex = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`";
ASCIndex += "abcdefghijklmnopqrstuvwxyz{|}~";
ASCIndex += "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}
integer asc(string char) {
return llSubStringIndex(ASCIndex, char) + 32;
}
integer getAdler32CRC(string str) {
integer crc;
integer i;
integer j = llStringLength(str);
integer low = 1;
integer high = 0;
integer char;
for(i=0; i<j; i++) {
char = asc(llGetSubString(str, i, i));
low = (low + char) % 65521;
high = (high + low) % 65521;
}
crc = high * 65536 + low;
return crc;
}
default {
state_entry() {
initAsc();
float startTime = llGetTime();
llOwnerSay("Computing Adler32 CRC on a big string, please wait...");
integer CRC = getAdler32CRC("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
llOwnerSay("Computed Adler32 CRC on 'Lorem ipsum...' in " + (string)(llGetTime() - startTime) + " seconds. The CRC value is " + (string)CRC + ".");
}
}