Basic Multi Encryption
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Here is a basic way of encrypting using several methods rolled into one.
Encryption Code
<lsl>string protection="201385testghub"; //Password for XOR Base 64 integer pad1; //Main pad to be sent in message integer pad2; //Roll over buffer pad to catch late messages using this number integer pad3; //Last roll over buffer pad to catch late messages using this number integer st; //Temp String
//List of characters you could type list from=[ "0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",":","-"]; //List of characters to replace yours with list replace=[">","<",";","d","'","{","[","}","]","%","^","&","*","(",")","_","-","+","g","=","$","£","@","!","±","§","#","€","¡","¢","∞","§","¶","•","ª","º","–","≠","æ","«","…","‘","“","≥","≤","÷","s","g","5","4","f","v","b","h","y","7","9","i","k","m","h","a","z","e"];
//Function to generate a random number based on server time, this number will generate the same in all scripts this code is in, the pad2 and pad3 are to catch messages using an old number once its switched, the longest a number is available for use is around 30 seconds or so. switch(){
st=(integer)("0x"+llGetSubString(llSHA1String((string)(llGetUnixTime()/10)+";'"),3,9)); st= -st; pad3=pad2; pad2=pad1; pad1=st;
}
//Encrypt message string encrypt(string msg){
string mess=msg; integer length=llStringLength(mess); msg=""; integer i=0; for(;i<length;++i){ string l=llGetSubString(mess,i,i); integer index=llListFindList(from,[l]); msg+=llList2String(replace,index); } msg=llXorBase64(llStringToBase64(msg),llStringToBase64(protection)); msg=llMD5String((string)llGetOwner(),1+(integer)llFrand(999999999))+"ß"+llStringToBase64((string)pad1)+"ß"+msg; return msg;
}
//Decrypt message
string decryption(string msg){
list data=llParseString2List(msg,["ß"],[]); data=llDeleteSubList(data,0,0); string temp=llBase64ToString(llList2String(data,0)); integer num=(integer)temp; if(num==pad1||num==pad2||num==pad3){ msg=llList2String(data,1); msg=llBase64ToString(llXorBase64(msg,llStringToBase64(protection))); string mess=msg; integer length=llStringLength(mess); msg=""; integer i=0; for(;i<length;++i){ string l=llGetSubString(mess,i,i); integer index=llListFindList(replace,[l]); msg+=llList2String(from,index); } } return msg;
}
//Random number salting
string salt(integer num){
string salt=""; salt=(string)(555555+(integer)llFrand(999999)); integer i=0; integer length=llGetListLength(replace); for(;i<num;++i){ integer ran=(integer)llFrand(length); salt+=llList2String(replace,ran); } return salt;
} default{
state_entry(){ switch(); llSetTimerEvent(5); string test=encrypt(salt(8)+":TestMessage"+(string)llGetOwner()+":"+"4056"); llOwnerSay(test); test=decryption(test); llOwnerSay(test); } timer(){ switch(); //llOwnerSay((string)pad1+"......"+(string)pad2+"...."+(string)pad3); }
}/<lsl>