Don't click here unless you want to be banned.

LSL Wiki : LibrarySimpleCypher

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl427.us.archive.org
Really this is just 2 functions (and a bunch of globals) for use in another script. The listen event will take a coma delimited password and string (myPass,myString) and both encode and decode the string with the password. It is merely for testing. Likely to be slow for long strings. This isn't truely secure, any decent computer, or someone with a little spare time and some context, will probably be able to decipher any message in short order.

Also see llXorBase64Strings for a different method of encrypting data.
This is what happens when I pull old scripts out of my inventory - yup, that function will do a better job than this, and was made well after I wrote this script. - AO

// Ama's Simple Cypher v. 0.3

// Feel free to reorganize either of these.  Infact, doing so is recommended.
// Just remember - these must match whatever strings are in the partner script you are communicating with.
string ASCII = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890`-=~!@#$%^&*()_+[]\\{}|;':\",./<>? ";
string CODE = " ABCDEFGHIJKLMNOPQRSTUVWXYZadbcefghijklmnopqrstuvwxyz1234567890`-=~!@#$%^&*()_+[]\\{}|;':\",./<>? ";
string PWD;
integer asciiLength;  // asciiLength = llStringLength(ASCII); in state_entry of default
integer passLength;
string ret;
integer i;
integer bit;
integer size;
list coms;

string encode(string mes, string pwd)
{
    ret = "";
    size = llStringLength(mes);
    passLength = llStringLength(pwd);
    for (i=0;i<size;i++)
    {
        bit = (llSubStringIndex(ASCII,llGetSubString(mes,i,i)) + (integer)llGetSubString(pwd,i%passLength,i%passLength) ) % asciiLength;
        ret +=  llGetSubString(CODE,bit,bit);
    }
    return ret;
}

string decode(string mes, string pwd)
{
    ret = "";
    size = llStringLength(mes);
    passLength = llStringLength(pwd);
    for (i=0;i<size;i++)
    {
        bit = (llSubStringIndex(CODE,llGetSubString(mes,i,i)) - (integer)llGetSubString(pwd,i%passLength,i%passLength) ) % asciiLength;
        ret +=  llGetSubString(ASCII,bit,bit);
    }
    return ret;
}

default
{
    state_entry()
    {
        asciiLength = llStringLength(ASCII);
        llListen(0,"",llGetOwner(),"");
    }

    listen(integer chan, string name, key id, string mes)
    {
        coms = llCSV2List(mes);
        llWhisper(0,encode(llList2String(coms,1),llList2String(coms,0)) + "," + decode(llList2String(coms,1),llList2String(coms,0)));
    }
}


ScriptLibrary / Examples
Comments [Hide comments/form]
Attach a comment to this page: