Difference between revisions of "User:Kireji Haiku/SIMchat headset"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}
<span id="top"></span>
<span id="top"></span>
<font color="red">Check out all my other </font>[[User:Kireji_Haiku|projects!]]
<div style="float:right;">__TOC__</div>
<div style="float:right;">__TOC__</div>
<div id="box">
<div id="box">
<div style="padding: 0.5em;">
<div style="padding: 0.5em;">
=SIMchat headset=
==General information:==


= SIMchat headset by [[User:Kireji Haiku|Kireji]] =
== General information: ==


If you want to use it, you should drop it into a <font color="red">childprim</font> of a linkset.
If you want to use it, you should drop it into a <font color="red">childprim</font> of a linkset.
This setup will give you the possibilty to forward your chat on a certain channel <font color="red">within</font> the whole region your are in and <font color="red">encrypt</font> it.
This setup will give you the possibilty to forward your chat on a certain channel <font color="red">within</font> the whole region your are in and <font color="red">encrypt</font> it.
Just make sure anybody you want to talk to has the same variables as you do.
Just make sure anybody you want to talk to has the same variables as you do.


[[File:SIMchat_Headset.jpg|thumb|700px|center|This is what it could look like. There's no particle system in the script, I just added it for demonstration purposes.]]
[[File:SIMchat_Headset.jpg|thumb|700px|center|This is what it could look like. There's no particle system in the script, I just added it for demonstration purposes.]]
Line 21: Line 17:
[[File:SIMchat_Headset_grey.jpg|thumb|700px|center|Yellow marker shows the root prim (parent), red marker shows the invisible linked prim (child) containing the script.]]
[[File:SIMchat_Headset_grey.jpg|thumb|700px|center|Yellow marker shows the root prim (parent), red marker shows the invisible linked prim (child) containing the script.]]


[[#top|Back to top!]]


== Script: ==


[[#top|Go to top!]]
<source lang="lsl2">
//  This script includes the XTEA-LSL-Implementation by:
//  - Morse Dillon
//  - Strife Onizuka
//  - Dedric Mauriac
//  - JB Kraft
//  http://wiki.secondlife.com/wiki/XTEA_Strong_Encryption_Implementation


==Script:==
//  Setup:
<lsl>
// 1. Make sure the object in which you want to use this script has more than one prim.
 
//  2. Make sure the object is modifiable by you.
/*
//  3. This script must go into a childprim of your object, it doesn't matter into which one.
*
//  4. After you have copied the script into your object, make sure everyone you want to talk to has the same
*
//    settings for KEY1, KEY2, KEY3, KEY4 and COMM_CHANNEL. You can use any valid, positive (!) integer number
* This script includes the XTEA-LSL-Implementation by:
//    for COMM_CHANNEL excluding PUBLIC_CHANNEL (which is 0) and DEBUG_CHANNEL (which is 2147483647). Do not use
* - Morse Dillon
//    a negative channel!
* - Strife Onizuka
//  5. When chatting, please type in local chat and add your channel. Example: If your COMM_CHANNEL was 9 then you'd type: '/9 hello'
* - Dedric Mauriac
//  6. The code is written for an avatar attachment (usually a headset / HUD) and will run in no-script areas.
* - JB Kraft
* http://wiki.secondlife.com/wiki/XTEA_Strong_Encryption_Implementation
*
*
* Setup:
* 1. Make sure the object in which you want to use this script has more than one prim.
* 2. Make sure the object is modifiable by you.
* 3. This script must go into a childprim of your object, it doesn't matter into which one.
* 4. After you have copied the script into your object, make sure everyone you want to talk to has the same
*    settings for KEY1, KEY2, KEY3, KEY4 and COMM_CHANNEL. You can use any valid, positive (!) integer number
*    for COMM_CHANNEL excluding PUBLIC_CHANNEL (which is 0) and DEBUG_CHANNEL (which is 2147483647). Do not use
*    a negative channel!
* 5. When chatting, please type in local chat and add your channel. Example: If your COMM_CHANNEL was 9 then you'd type: "/9 hello"
* 6. The code is written for an avatar attachment (usually a headset / HUD) and will run in no-script areas.
*
*
*/
 
integer KEY1 = 11111111;
integer KEY2 = 22222222;
integer KEY3 = 33333333;
integer KEY4 = 44444444;


integer COMM_CHANNEL = 9;
integer COMM_CHANNEL = 9;
 
integer KEY1        = 11111111;
/*
integer KEY2        = 22222222;
*
integer KEY3        = 33333333;
* If you're not sure what you're doing,
integer KEY4        = 44444444;
* do NOT change anything below!
*
//  If you're not sure what you're doing,
*/
//  do NOT change anything below!
 
key ownerKey;
key     ownerKey;
string ownerName;
string ownerName;
 
integer CYCLES = 6;
integer CYCLES   = 6;
 
list cypherkey = [];
list   cypherkey;
integer delta = 0x9E3779B9;
integer delta     = 0x9E3779B9;
 
integer ord(string chr)
integer ord(string chr)
{
{
    if (llStringLength(chr) != 1)
    {
        return ERR_GENERIC;
    }
    if (chr == " ")
    {
        return 32;
    }
     string ASCII = "            \n                    !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
     string ASCII = "            \n                    !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
    if(llStringLength(chr) != 1)
        return -1;
    if(chr == " ")
        return 32;
     return llSubStringIndex(ASCII, chr);
     return llSubStringIndex(ASCII, chr);
}
}
 
string chr(integer i)
string chr(integer i)
{
{
    string ASCII = "            \n                    !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
     i %= 127;
     i %= 127;


     return llGetSubString(ASCII, i, i);
     string ASCII = "            \n                    !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
    return llGetSubString(ASCII, i, i);
}
}
 
string DWord2Hex(integer m)
string DWord2Hex(integer m)
{
{
     string result;
     string result;
    integer i = 0;
     integer index;
     integer index = 0;
     string characters = "0123456789ABCDEF";   
 
     string characters = "0123456789ABCDEF";   
    integer i;
 
     for (; i < 8; i++)
     for (i = 0; i < 8; i++)
     {
     {
         index  = (m >> (i * 4)) & 0xF;
         index  = (m >> (i * 4)) & 0xF;
         result = llInsertString(result, 0, llGetSubString(characters,index,index));
         result = llInsertString(result, 0, llGetSubString(characters, index, index));
     }
     }
 
     return result;
     return result;
}
}
 
integer Hex2DWord(string m)
integer Hex2DWord(string m)
{
{
     integer result = 0;
     integer result;
    integer i = 0;
     string digit;
     string digit;
     integer value;
     integer value;
     integer index;
     integer index;
 
     string characters = "0123456789ABCDEF";
     string characters = "0123456789ABCDEF";
 
     for (i = 0; i < 8; i++)
    integer i;
     for (; i < 8; i++)
     {
     {
        index = 8 - (i + 1);
        index = 8 - (i + 1);
         digit = llGetSubString(m,index,index);
         digit = llGetSubString(m,index,index);
 
         value = llSubStringIndex(characters, digit);
         value = llSubStringIndex(characters, digit);
 
         result = result | value << (i * 4);
         result = result | value << (i * 4);
     }
     }
 
     return result;
     return result;
}
}
 
string Encrypt(string cleartext)
string Encrypt(string cleartext)
{
{
        integer dword1 = 0;
    integer cyphertext_numeric;
        integer dword2 = 0;
    integer dword1;
        integer cyphertext_numeric;
    integer dword2;
        list cypherblock;
    list   cypherblock;
        string cyphertext = "";
    string cyphertext;


        while(llStringLength(cleartext) & 0x7)
    while(llStringLength(cleartext) & 0x7)
            cleartext += " ";
    {
        cleartext += " ";
    }


        integer stringlength = llStringLength(cleartext);
    integer character;
        integer i=0;
    integer stringlength = llStringLength(cleartext);  
        integer character;


        while (i < stringlength)
    integer i;
        {
    while (i < stringlength)
            dword1 =  ord(llGetSubString(cleartext,i,i));
    {
            i++;
        dword1 =  ord(llGetSubString(cleartext,i,i));
            dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 8);
        i++;
            i++;
        dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 8);
            dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 16);
        i++;
            i++;
        dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 16);
            dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 24);
        i++;
            i++;
        dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 24);
        i++;


            dword2 =  ord(llGetSubString(cleartext,i,i));
        dword2 =  ord(llGetSubString(cleartext,i,i));
            i++;
        i++;
            dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 8;
        dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 8;
            i++;
        i++;
            dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 16;
        dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 16;
            i++;
        i++;
            dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 24;
        dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 24;
            i++;
        i++;


            cypherblock = TEAEncrypt(dword1,dword2,cypherkey);
        cypherblock = TEAEncrypt(dword1,dword2,cypherkey);


            cyphertext = cyphertext + DWord2Hex(llList2Integer(cypherblock,0)) + DWord2Hex(llList2Integer(cypherblock,1));
        cyphertext = cyphertext + DWord2Hex(llList2Integer(cypherblock,0)) + DWord2Hex(llList2Integer(cypherblock,1));


            dword1 = 0;
        dword1     = 0;
            dword2 = 0;
        dword2     = 0;
            cypherblock = [];
        cypherblock = [];
        }
    }


        return cyphertext;      
    return cyphertext;
}   
}   
 
string Decrypt(string cyphertext)
string Decrypt(string cyphertext)
{
{
        string hexvalue1 = "";
    integer dword1;
        string hexvalue2 = "";
    integer dword2;
        integer dword1 = 0;
    list   clearblock;
        integer dword2 = 0;
    string cleartext;
        list clearblock = [];
    string  hexvalue1;
        string cleartext = "";
    string  hexvalue2;
        integer i;


        while (i < llStringLength(cyphertext))
    integer i;
        {
    while (i < llStringLength(cyphertext))
            hexvalue1 += llGetSubString(cyphertext,i,i + 7);
    {
            i = i + 8;
        hexvalue1 += llGetSubString(cyphertext,i,i + 7);
        i = i + 8;


            hexvalue2 += llGetSubString(cyphertext,i,i + 7);
        hexvalue2 += llGetSubString(cyphertext,i,i + 7);
            i = i + 8;
        i = i + 8;


            dword1 = Hex2DWord(hexvalue1);
        dword1 = Hex2DWord(hexvalue1);
            dword2 = Hex2DWord(hexvalue2);  
        dword2 = Hex2DWord(hexvalue2);  


            clearblock = TEADecrypt(dword1, dword2, cypherkey);
        clearblock = TEADecrypt(dword1, dword2, cypherkey);


            cleartext += chr( llList2Integer(clearblock,0) & 0x000000FF);
        cleartext += chr( llList2Integer(clearblock, 0) & 0x000000FF);
            cleartext += chr( (llList2Integer(clearblock,0) & 0x0000FF00)  >> 8);
        cleartext += chr( (llList2Integer(clearblock, 0) & 0x0000FF00)  >> 8);
            cleartext += chr( (llList2Integer(clearblock,0) & 0x00FF0000)  >> 16);
        cleartext += chr( (llList2Integer(clearblock, 0) & 0x00FF0000)  >> 16);
            cleartext += chr( (llList2Integer(clearblock,0) & 0xFF000000)  >> 24);
        cleartext += chr( (llList2Integer(clearblock, 0) & 0xFF000000)  >> 24);


            cleartext += chr( llList2Integer(clearblock,1) & 0x000000FF);
        cleartext += chr( llList2Integer(clearblock, 1) & 0x000000FF);
            cleartext += chr( (llList2Integer(clearblock,1) & 0x0000FF00)  >> 8);
        cleartext += chr( (llList2Integer(clearblock, 1) & 0x0000FF00)  >> 8);
            cleartext += chr( (llList2Integer(clearblock,1) & 0x00FF0000)  >> 16);
        cleartext += chr( (llList2Integer(clearblock, 1) & 0x00FF0000)  >> 16);
            cleartext += chr( (llList2Integer(clearblock,1) & 0xFF000000)  >> 24);
        cleartext += chr( (llList2Integer(clearblock, 1) & 0xFF000000)  >> 24);


            hexvalue1 = "";
        hexvalue1 = "";
            hexvalue2 = "";
        hexvalue2 = "";
            dword1 = 0;
        dword1     = 0;
            dword2 = 0;
        dword2     = 0;
            clearblock = [];
        clearblock = [];
        }
    }


        return cleartext;      
    return cleartext;
}
}
 
list TEAEncrypt(integer dword1, integer dword2,list cypherkey)
list TEAEncrypt(integer dword1, integer dword2,list cypherkey)
{
{
            list cryptlist = [];
    integer sum;
    list   cryptlist;


            integer n = CYCLES;
    integer n = CYCLES;
 
    while (n-- > 0)
            integer sum = 0;
    {
 
        dword1 = dword1 + ( ( dword2 << 4 ^ ((dword2 >> 5) & 0x07FFFFFF) ) + dword2 ^ sum + llList2Integer(cypherkey, (sum & 3) ) );
            while (n-- > 0)
        sum += delta;
            {
        dword2 = dword2 + ( ( dword1 << 4 ^ ((dword1 >> 5) & 0x07FFFFFF) ) + dword1 ^ sum + llList2Integer(cypherkey, ((sum >> 11) & 3) ) );
                dword1 = dword1 + ( ( dword2 << 4 ^ ((dword2 >> 5) & 0x07FFFFFF) ) + dword2 ^ sum + llList2Integer(cypherkey, (sum & 3) ) );
    }
                sum += delta;
                dword2 = dword2 + ( ( dword1 << 4 ^ ((dword1 >> 5) & 0x07FFFFFF) ) + dword1 ^ sum + llList2Integer(cypherkey, ((sum >> 11) & 3) ) );
            }


            cryptlist = [dword1,dword2];
    cryptlist = [dword1,dword2];


            return cryptlist;
    return cryptlist;
}
}
 
list TEADecrypt(integer dword1, integer dword2,list cypherkey)
list TEADecrypt(integer dword1, integer dword2,list cypherkey)
{
{
            list cryptlist = [];
    integer sum = delta * CYCLES;
    list   cryptlist;


            integer n = CYCLES;
    integer n = CYCLES;
    while (n-- > 0)
    {
        dword2 = dword2 - ( ( dword1 << 4 ^ ((dword1 >> 5) & 0x07FFFFFF) ) + dword1 ^ sum + llList2Integer(cypherkey, ((sum >> 11) & 3) ) );
        sum -= delta;
        dword1 = dword1 - ( ( dword2 << 4 ^ ((dword2 >> 5) & 0x07FFFFFF) ) + dword2 ^ sum + llList2Integer(cypherkey, (sum & 3) ) );       
    }


            integer sum = delta * CYCLES;
    cryptlist = [dword1,dword2];
 
    return cryptlist;
            while (n-- > 0)
            {
                dword2 = dword2 - ( ( dword1 << 4 ^ ((dword1 >> 5) & 0x07FFFFFF) ) + dword1 ^ sum + llList2Integer(cypherkey, ((sum >> 11) & 3) ) );
                sum -= delta;
                dword1 = dword1 - ( ( dword2 << 4 ^ ((dword2 >> 5) & 0x07FFFFFF) ) + dword2 ^ sum + llList2Integer(cypherkey, (sum & 3) ) );       
            }
 
            cryptlist = [dword1,dword2];
            return cryptlist;
}
}
 
default
default
{
{
Line 275: Line 257:
         }
         }
     }
     }
 
     changed(integer change)
     changed(integer change)
     {
     {
Line 284: Line 266:
         }
         }
     }
     }
 
     state_entry()
     state_entry()
     {
     {
         ownerKey = llGetOwner();
         ownerKey = llGetOwner();
         ownerName = llKey2Name(ownerKey);
         ownerName = llKey2Name(ownerKey);
         cypherkey = [KEY1,KEY2,KEY3,KEY4];
         cypherkey = [KEY1, KEY2, KEY3, KEY4];


        string timeStamp = llGetTimestamp();
         llSetLinkPrimitiveParamsFast(LINK_THIS, [
         llSetLinkPrimitiveParamsFast(LINK_THIS, [
             PRIM_NAME, ownerName,
             PRIM_NAME, ownerName,
             PRIM_DESC, "Last reset: " + llGetTimestamp()]);
             PRIM_DESC, timeStamp]);
        llRequestPermissions(ownerKey, PERMISSION_TAKE_CONTROLS);


        llRequestPermissions(ownerKey, PERMISSION_TAKE_CONTROLS);
         llListen(COMM_CHANNEL, "", NULL_KEY, "");
         llListen(COMM_CHANNEL, "", NULL_KEY, "");
     }
     }
 
     listen(integer channel, string name, key id, string message)
     listen(integer channel, string name, key id, string message)
     {
     {
         if (channel != COMM_CHANNEL)
         if (channel != COMM_CHANNEL)
        {
             return;
             return;
 
        }
         if (id == ownerKey)
         if (id == ownerKey)
         {
         {
Line 319: Line 306:
         }
         }
     }
     }
 
     run_time_permissions(integer perm)
     run_time_permissions(integer perm)
     {
     {
         if (perm & PERMISSION_TAKE_CONTROLS)
         if (perm & PERMISSION_TAKE_CONTROLS)
        {
             llTakeControls(CONTROL_DOWN, TRUE, TRUE);
             llTakeControls(CONTROL_DOWN, TRUE, TRUE);
        }
     }
     }
 
//  needs a control event for no-script-area hack
     control(key id, integer level, integer edge)
     control(key id, integer level, integer edge)
     {
     {
Line 331: Line 321:
     }
     }
}
}
</lsl>
</source>
[[#top|Go to top!]]
 
</div></div>
[[#top|Back to top!]]
</div>
</div>

Latest revision as of 19:11, 24 January 2015

SIMchat headset by Kireji

General information:

If you want to use it, you should drop it into a childprim of a linkset. This setup will give you the possibilty to forward your chat on a certain channel within the whole region your are in and encrypt it. Just make sure anybody you want to talk to has the same variables as you do.

This is what it could look like. There's no particle system in the script, I just added it for demonstration purposes.
Yellow marker shows the root prim (parent), red marker shows the invisible linked prim (child) containing the script.

Back to top!

Script:

//  This script includes the XTEA-LSL-Implementation by:
//  - Morse Dillon
//  - Strife Onizuka
//  - Dedric Mauriac
//  - JB Kraft
//  http://wiki.secondlife.com/wiki/XTEA_Strong_Encryption_Implementation

//  Setup:
//  1. Make sure the object in which you want to use this script has more than one prim.
//  2. Make sure the object is modifiable by you.
//  3. This script must go into a childprim of your object, it doesn't matter into which one.
//  4. After you have copied the script into your object, make sure everyone you want to talk to has the same
//     settings for KEY1, KEY2, KEY3, KEY4 and COMM_CHANNEL. You can use any valid, positive (!) integer number
//     for COMM_CHANNEL excluding PUBLIC_CHANNEL (which is 0) and DEBUG_CHANNEL (which is 2147483647). Do not use
//     a negative channel!
//  5. When chatting, please type in local chat and add your channel. Example: If your COMM_CHANNEL was 9 then you'd type: '/9 hello'
//  6. The code is written for an avatar attachment (usually a headset / HUD) and will run in no-script areas.

 
integer COMM_CHANNEL = 9;
integer KEY1         = 11111111;
integer KEY2         = 22222222;
integer KEY3         = 33333333;
integer KEY4         = 44444444;
 
//  If you're not sure what you're doing,
//  do NOT change anything below!
 
key     ownerKey;
string  ownerName;
 
integer CYCLES    = 6;
 
list    cypherkey;
integer delta     = 0x9E3779B9;
 
integer ord(string chr)
{
    if (llStringLength(chr) != 1)
    {
        return ERR_GENERIC;
    }
    if (chr == " ")
    {
        return 32;
    }
 
    string ASCII = "             \n                    !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
    return llSubStringIndex(ASCII, chr);
}
 
string chr(integer i)
{
    i %= 127;

    string ASCII = "             \n                    !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
     return llGetSubString(ASCII, i, i);
}
 
string DWord2Hex(integer m)
{
    string  result;
    integer index;
    string  characters = "0123456789ABCDEF";   
 
    integer i;
    for (; i < 8; i++)
    {
        index  = (m >> (i * 4)) & 0xF;
        result = llInsertString(result, 0, llGetSubString(characters, index, index));
    }
 
    return result;
}
 
integer Hex2DWord(string m)
{
    integer result;
    string digit;
    integer value;
    integer index;
 
    string characters = "0123456789ABCDEF";
 
    integer i;
    for (; i < 8; i++)
    {
        index = 8 - (i + 1);
        digit = llGetSubString(m,index,index);
 
        value = llSubStringIndex(characters, digit);
 
        result = result | value << (i * 4);
    }
 
    return result;
}
 
string Encrypt(string cleartext)
{
    integer cyphertext_numeric;
    integer dword1;
    integer dword2;
    list    cypherblock;
    string  cyphertext;

    while(llStringLength(cleartext) & 0x7)
    {
        cleartext += " ";
    }

    integer character;
    integer stringlength = llStringLength(cleartext); 

    integer i;
    while (i < stringlength)
    {
        dword1 =  ord(llGetSubString(cleartext,i,i));
        i++;
        dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 8);
        i++;
        dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 16);
        i++;
        dword1 =  dword1 | (ord(llGetSubString(cleartext,i,i)) << 24);
        i++;

        dword2 =  ord(llGetSubString(cleartext,i,i));
        i++;
        dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 8;
        i++;
        dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 16;
        i++;
        dword2 =  dword2 | ord(llGetSubString(cleartext,i,i)) << 24;
        i++;

        cypherblock = TEAEncrypt(dword1,dword2,cypherkey);

        cyphertext = cyphertext + DWord2Hex(llList2Integer(cypherblock,0)) + DWord2Hex(llList2Integer(cypherblock,1));

        dword1      = 0;
        dword2      = 0;
        cypherblock = [];
     }

    return cyphertext;
}  
 
string Decrypt(string cyphertext)
{
    integer dword1;
    integer dword2;
    list    clearblock;
    string  cleartext;
    string  hexvalue1;
    string  hexvalue2;

    integer i;
    while (i < llStringLength(cyphertext))
    {
        hexvalue1 += llGetSubString(cyphertext,i,i + 7);
        i = i + 8;

        hexvalue2 += llGetSubString(cyphertext,i,i + 7);
        i = i + 8;

        dword1 = Hex2DWord(hexvalue1);
        dword2 = Hex2DWord(hexvalue2); 

        clearblock = TEADecrypt(dword1, dword2, cypherkey);

        cleartext += chr( llList2Integer(clearblock, 0) & 0x000000FF);
        cleartext += chr( (llList2Integer(clearblock, 0) & 0x0000FF00)  >> 8);
        cleartext += chr( (llList2Integer(clearblock, 0) & 0x00FF0000)  >> 16);
        cleartext += chr( (llList2Integer(clearblock, 0) & 0xFF000000)  >> 24);

        cleartext += chr( llList2Integer(clearblock, 1) & 0x000000FF);
        cleartext += chr( (llList2Integer(clearblock, 1) & 0x0000FF00)  >> 8);
        cleartext += chr( (llList2Integer(clearblock, 1) & 0x00FF0000)  >> 16);
        cleartext += chr( (llList2Integer(clearblock, 1) & 0xFF000000)  >> 24);

        hexvalue1  = "";
        hexvalue2  = "";
        dword1     = 0;
        dword2     = 0;
        clearblock = [];
     }

    return cleartext;
}
 
list TEAEncrypt(integer dword1, integer dword2,list cypherkey)
{
    integer sum;
    list    cryptlist;

    integer n = CYCLES;
    while (n-- > 0)
    {
        dword1 = dword1 + ( ( dword2 << 4 ^ ((dword2 >> 5) & 0x07FFFFFF) ) + dword2 ^ sum + llList2Integer(cypherkey, (sum & 3) ) );
        sum += delta;
        dword2 = dword2 + ( ( dword1 << 4 ^ ((dword1 >> 5) & 0x07FFFFFF) ) + dword1 ^ sum + llList2Integer(cypherkey, ((sum >> 11) & 3) ) );
    }

    cryptlist = [dword1,dword2];

    return cryptlist;
}
 
list TEADecrypt(integer dword1, integer dword2,list cypherkey)
{
    integer sum = delta * CYCLES;
    list    cryptlist;

    integer n = CYCLES;
    while (n-- > 0)
    {
        dword2 = dword2 - ( ( dword1 << 4 ^ ((dword1 >> 5) & 0x07FFFFFF) ) + dword1 ^ sum + llList2Integer(cypherkey, ((sum >> 11) & 3) ) );
        sum -= delta;
        dword1 = dword1 - ( ( dword2 << 4 ^ ((dword2 >> 5) & 0x07FFFFFF) ) + dword2 ^ sum + llList2Integer(cypherkey, (sum & 3) ) );        
    }

    cryptlist = [dword1,dword2];
    return cryptlist;
}
 
default
{
    on_rez(integer start_param)
    {
        if (llGetOwner() != ownerKey)
        {
            llReleaseControls();
            llResetScript();
        }
    }
 
    changed(integer change)
    {
        if (change & CHANGED_OWNER)
        {
            llReleaseControls();
            llResetScript();
        }
    }
 
    state_entry()
    {
        ownerKey  = llGetOwner();
        ownerName = llKey2Name(ownerKey);
        cypherkey = [KEY1, KEY2, KEY3, KEY4];

        string timeStamp = llGetTimestamp();
 
        llSetLinkPrimitiveParamsFast(LINK_THIS, [
            PRIM_NAME, ownerName,
            PRIM_DESC, timeStamp]);
 
        llRequestPermissions(ownerKey, PERMISSION_TAKE_CONTROLS);

        llListen(COMM_CHANNEL, "", NULL_KEY, "");
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if (channel != COMM_CHANNEL)
        {
            return;
        }
 
        if (id == ownerKey)
        {
            llRegionSay(COMM_CHANNEL, Encrypt(message));
            llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_NAME, ""]);
            llOwnerSay("/me [" + ownerName + "]: '" + message + "'");
            llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_NAME, ownerName]);
        }
        else if (llGetAgentSize(id) == ZERO_VECTOR)
        {
            message = Decrypt(message);
            llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_NAME, ""]);
            llOwnerSay("/me [" + name + "]: '" + message + "'");
            llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_NAME, ownerName]);
        }
    }
 
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TAKE_CONTROLS)
        {
            llTakeControls(CONTROL_DOWN, TRUE, TRUE);
        }
    }
 
//  needs a control event for no-script-area hack
    control(key id, integer level, integer edge)
    {
        ;
    }
}

Back to top!