Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Encryption ARCFOUR_Strong_Encryption_Implement  

ARCFOUR_Strong_Encryption_Implement

Contributors
// * Nekow42 Zarf (...

Category: Encryption
By : Nekow42 Zarf
Created: 2010-12-27 Edited: 2010-12-27
Worlds: Second Life

the Zip file

Download all files for ARCFOUR_Strong_Encryption_Implement
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. ARCFOUR_Strong_Encryption_Implement_1.lsl
Get file # 2. ARCFOUR_Strong_Encryption_Implement_2.lsl
Get file # 3. ARCFOUR_Strong_Encryption_Implement_3.lsl
1 // Encryption
2 //This is an exact implementation of ARCFOUR that passes the test vectors.
3
4 //Note: Key setup is a long
5 //process taking over 20 seconds.
6
7 //Notes on use: The same password can be used more than once, but the nonce always has to be different
8 //(something random). You can use this to secure inter-object communication by having a shared (but secret)
9 //password, and have the two objects exchange a nonce beforehand. A warning, there is no garbage fitering,
10 //so the state array could be polluted by someone injecting fake strings.
11 //To prevent this, the first thing exchanged encrypted
12 //could be a negative port number, and the two objects could listen only for each other's key. For proper
13 //decryption, messages must arrive in the exact order they were encrypted.
14
15 //This work is licensed under a http://creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0 Unported License
16 //Please credit Nekow42 Zarf.
17 //Nardok Corrimal, and Strife Onizuka contributed and need credit too.
18 list theState;
19 integer i;
20 integer j;
21 //===================================================//
22 // Combined Library //
23 // "Nov 3 2007", "00:46:15" //
24 // Copyright (C) 2004-2007, Strife Onizuka (cc-by) //
25 // http://creativecommons.org/licenses/by/3.0/ //
26 //===================================================//
27 //{
28 integer UTF8ToUnicodeInteger(string input)//Mono Safe, LSO Safe
29 {
30 integer result = llBase64ToInteger(llStringToBase64(input = llGetSubString(input,0,0)));
31 if(result & 0x80000000){
32 return 0;
33 }
34 return result >> 24;
35 }
36
37
38 string UnicodeIntegerToUTF8(integer input)//Mono Safe, LSO Safe
39 {
40 integer bytes = llCeil(llLog(input) / 0.69314718055994530941723212145818);
41 bytes = (input >= 0x80) * (bytes + ~(((1 << bytes) - input) > 0)) / 5;//adjust
42 string result = "%" + byte2hex((input >> (6 * bytes)) | ((0x3F80 >> bytes) << !bytes));
43 while(bytes)
44 result += "%" + byte2hex((((input >> (6 * (bytes = ~-bytes))) | 0x80) & 0xBF));
45 return llUnescapeURL(result);
46 }
47
48 string byte2hex(integer x)//Mono Safe, LSO Safe
49 {//Helper function for use with unicode characters.
50 integer y = (x >> 4) & 0xF;
51 return llGetSubString(hexc, y, y) + llGetSubString(hexc, x & 0xF, x & 0xF);
52 }//This function would benifit greatly from the DUP opcode, it would remove 19 bytes.
53
54 string hexc="0123456789ABCDEF";
55
56 //} Combined Library
57 KeySetup(string password, string nonce)
58 {
59 //All addition is done modulous
60 list WholePassword;
61 list statePartOne = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75];
62 list statePartTwo = [76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150];
63 list statePartThree = [151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225];
64 list statePartFour = [226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255];
65 theState = (statePartOne = statePartTwo = statePartThree = statePartFour = []) + statePartOne + statePartTwo + statePartThree + statePartFour;
66 integer swapper;
67 //setup the plaintext list
68 integer ThePerpetualMax;
69 //setup the password. Use i since we already have it.
70 //New addition in 1.1, use an MD5 hashing function on the password
71 password = llMD5String(password + nonce,0);
72 for(i = 0; i < 31; i+=2)
73 {
74 WholePassword = (WholePassword = []) + WholePassword + (integer)("0x"+llGetSubString(password,i,i+1));
75 }
76 //Now WholePassword is equal to a list of the hex digits of the MD5 of the password plus the nonce
77 i=0;
78 j=0;
79 //mix init, this sets up the ARCFOUR PRNG
80 ThePerpetualMax = llGetListLength(WholePassword);
81 for(i=0 ; i < 256; i++)
82 {
83 //Mix step one
84 //Add to the variable j the contents of the ith element of the state array and the nth element of the key, where n is equal to i modulo the length of the key.
85 j = (j + llList2Integer(theState, i) + llList2Integer(WholePassword,i % ThePerpetualMax)) % 256;
86 //Mix step two. Swap the ith element and the jth element of the state array
87 swapper = llList2Integer(theState, i);
88 theState=llListReplaceList(theState, [llList2Integer(theState,j)] ,i,i);
89 theState=llListReplaceList(theState, [swapper],j,j);
90 }
91 i=0;
92 j=0;
93 //Key setup is complete!
94
95 }
96 string EncryptText(string plaintext)
97 //This does not repeat key setup, but continues with the same state array and values for i and j
98 {
99 //All addition is done modulous
100 list PlaintextBytes;
101 string CipheredBytes;
102 integer n;
103 integer counter;
104 integer swapper;
105 integer ByteToAdd;
106 //setup the plaintext list
107 integer ThePerpetualMax;
108 ThePerpetualMax = llStringLength(plaintext);
109 for(counter = 0; counter < ThePerpetualMax; counter++)
110 {
111 PlaintextBytes = (PlaintextBytes = []) + PlaintextBytes + [UTF8ToUnicodeInteger(llGetSubString(plaintext,counter,counter))];
112
113 }
114 ThePerpetualMax = llGetListLength(PlaintextBytes);
115 for(counter=0;counter < ThePerpetualMax;counter++)
116 {
117 //The variable i is incremented by one
118 i = (i + 1) % 256;
119 //The contents of the ith element of the state array is then added to j
120 j = (j + llList2Integer(theState, i)) % 256;
121 //The ith and jth elements of the state array are swapped and their contents are added together to form a new value n.
122 swapper = llList2Integer(theState, i);
123 theState=llListReplaceList(theState, [llList2Integer(theState,j)] ,i,i);
124 theState=llListReplaceList(theState, [swapper],j,j);
125 n = (llList2Integer(theState, i) + llList2Integer(theState, j)) % 256;
126 //The nth element of the state array is then combined with the message byte, using a bit by bit exclusive-or operation, to form the output byte.
127 ByteToAdd = llList2Integer(theState, n) ^ llList2Integer(PlaintextBytes, counter);
128 CipheredBytes = CipheredBytes + byte2hex(ByteToAdd);
129 }
130
131
132 return CipheredBytes;
133 }
134 default
135 {
136
137 touch_start(integer total_number)
138 {
139 llOwnerSay("Key is 'Key', plaintext is 'Plaintext'. Output:");
140 KeySetup("Key","");
141 llOwnerSay("Key setup complete. Encrypting now...");
142 llOwnerSay(EncryptText("Plaintext"));
143 }
144 }

ARCFOUR_Strong_Encryption_Implement

Decryption

Category: Encryption
By : Nekow42 Zarf
Created: 2010-12-27 Edited: 2010-12-27
Worlds: Second Life

1 //This is an exact implementation of ARCFOUR that passes the test vectors.
2
3 //Note: Key setup is a long
4 //process taking over 20 seconds.
5
6 //Notes on use: The same password can be used more than once, but the nonce always has to be different
7 //(something random). You can use this to secure inter-object communication by having a shared (but secret)
8 //password, and have the two objects exchange a nonce beforehand. A warning, there is no garbage fitering,
9 //so the state array could be polluted by someone injecting fake strings.
10 //To prevent this, the first thing exchanged encrypted
11 //could be a negative port number, and the two objects could listen only for each other's key. For proper
12 //decryption, messages must arrive in the exact order they were encrypted.
13
14 //This work is licensed under a http://creativecommons.org/licenses/by/3.0/ Creative Commons Attribution 3.0 Unported License
15 //Please credit Nekow42 Zarf.
16 //Nardok Corrimal, and Strife Onizuka contributed and need credit too.
17 list theState;
18 integer i;
19 integer j;
20 //===================================================//
21 // Combined Library //
22 // "Nov 3 2007", "00:46:15" //
23 // Copyright (C) 2004-2007, Strife Onizuka (cc-by) //
24 // http://creativecommons.org/licenses/by/3.0/ //
25 //===================================================//
26 //{
27 integer UTF8ToUnicodeInteger(string input)//Mono Safe, LSO Safe
28 {
29 integer result = llBase64ToInteger(llStringToBase64(input = llGetSubString(input,0,0)));
30 if(result & 0x80000000){
31 return 0;
32 }
33 return result >> 24;
34 }
35
36
37 string UnicodeIntegerToUTF8(integer input)//Mono Safe, LSO Safe
38 {
39 integer bytes = llCeil(llLog(input) / 0.69314718055994530941723212145818);
40 bytes = (input >= 0x80) * (bytes + ~(((1 << bytes) - input) > 0)) / 5;//adjust
41 string result = "%" + byte2hex((input >> (6 * bytes)) | ((0x3F80 >> bytes) << !bytes));
42 while(bytes)
43 result += "%" + byte2hex((((input >> (6 * (bytes = ~-bytes))) | 0x80) & 0xBF));
44 return llUnescapeURL(result);
45 }
46
47 string byte2hex(integer x)//Mono Safe, LSO Safe
48 {//Helper function for use with unicode characters.
49 integer y = (x >> 4) & 0xF;
50 return llGetSubString(hexc, y, y) + llGetSubString(hexc, x & 0xF, x & 0xF);
51 }//This function would benefit greatly from the DUP opcode, it would remove 19 bytes.
52
53 string hexc="0123456789ABCDEF";
54
55 //} Combined Library
56 KeySetup(string password, string nonce)
57 {
58 list WholePassword;
59 list statePartOne = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75];
60 list statePartTwo = [76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150];
61 list statePartThree = [151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225];
62 list statePartFour = [226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255];
63 theState = (statePartOne = statePartTwo = statePartThree = statePartFour = []) + statePartOne + statePartTwo + statePartThree + statePartFour;
64 integer swapper;
65 //setup the plaintext list
66 integer ThePerpetualMax;
67 //setup the password. Use i since we already have it.
68 //New addition in 1.1, use an MD5 hashing function on the password
69 password = llMD5String(password + nonce,0);
70 for(i = 0; i < 31; i+=2)
71 {
72 WholePassword = (WholePassword = []) + WholePassword + (integer)("0x"+llGetSubString(password,i,i+1));
73 }
74 //Now WholePassword is equal to a list of the hex digits of the MD5 of the password plus the nonce
75 i=0;
76 j=0;
77 //mix init, this sets up the ARCFOUR PRNG
78 ThePerpetualMax = llGetListLength(WholePassword);
79 for(i=0 ; i < 256; i++)
80 {
81 //Mix step one
82 //Add to the variable j the contents of the ith element of the state array and the nth element of the key, where n is equal to i modulo the length of the key.
83 j = (j + llList2Integer(theState, i) + llList2Integer(WholePassword,i % ThePerpetualMax)) % 256;
84 //Mix step two. Swap the ith element and the jth element of the state array
85 swapper = llList2Integer(theState, i);
86 theState=llListReplaceList(theState, [llList2Integer(theState,j)] ,i,i);
87 theState=llListReplaceList(theState, [swapper],j,j);
88 }
89 i=0;
90 j=0;
91 //Key setup is complete!
92 }
93 string DecryptText(string ciphertext)
94 {
95 //This does not repeat key setup, but continues with the same state array and values for i and j
96 list CiphertextBytes;
97 string DecryptedString;
98 integer n;
99 integer counter;
100 integer swapper;
101 integer ByteToAdd;
102 //setup the plaintext list
103 integer ThePerpetualMax;
104 ThePerpetualMax = llStringLength(ciphertext) - 1;
105 for(counter = 0; counter < ThePerpetualMax; counter+=2)
106 {
107 CiphertextBytes = (CiphertextBytes = []) + CiphertextBytes + (integer)("0x"+llGetSubString(ciphertext,counter,counter+1));
108 }
109 //setup the password. Use i since we already have it.
110 ThePerpetualMax = llGetListLength(CiphertextBytes);
111 for(counter=0;counter < ThePerpetualMax;counter++)
112 {
113 //The variable i is incremented by one
114 i = (i + 1) % 256;
115 //The contents of the ith element of the state array is then added to j
116 j = (j + llList2Integer(theState, i)) % 256;
117 //The ith and jth elements of the state array are swapped and their contents are added together to form a new value n.
118 swapper = llList2Integer(theState, i);
119 theState=llListReplaceList(theState, [llList2Integer(theState,j)] ,i,i);
120 theState=llListReplaceList(theState, [swapper],j,j);
121 n = (llList2Integer(theState, i) + llList2Integer(theState, j)) % 256;
122 //The nth element of the state array is then combined with the message byte, using a bit by bit exclusive-or operation, to form the output byte.
123 ByteToAdd = llList2Integer(theState, n) ^ llList2Integer(CiphertextBytes, counter);
124 DecryptedString = DecryptedString + UnicodeIntegerToUTF8(ByteToAdd);
125 }
126 return DecryptedString;
127 }
128 default
129 {
130
131 touch_start(integer total_number)
132 {
133 llOwnerSay( "Key Setup");
134 KeySetup("Key","");
135 llOwnerSay( "Decrypting test string.");
136 llOwnerSay(DecryptText("506C61696E74657874"));
137 }
138 }

ARCFOUR_Strong_Encryption_Implement

Test Vectors for ARCFOUR

Test vectors are from RC4 Summary

This vectors are not official, but are handy for anyone testing an ARCFOUR implementation.

RC4( "Key", "Plaintext" ) == BBF316E8D940AF0AD3

In decimal, the output is "187, 243, 22, 232, 217, 64, 175, 10, 211"

This code shows that it passes the test vector:

Category: Encryption
By : Nekow42 Zarf
Created: 2010-12-27 Edited: 2010-12-27
Worlds: Second Life

1 list theState;
2 integer i;
3 integer j;
4 //===================================================//
5 // Combined Library //
6 // "Nov 3 2007", "00:46:15" //
7 // Copyright (C) 2004-2007, Strife Onizuka (cc-by) //
8 // http://creativecommons.org/licenses/by/3.0/ //
9 //===================================================//
10 //{
11 integer UTF8ToUnicodeInteger(string input)//Mono Safe, LSO Safe
12 {
13 integer result = llBase64ToInteger(llStringToBase64(input = llGetSubString(input,0,0)));
14 if(result & 0x80000000){
15 return 0;
16 }
17 return result >> 24;
18 }
19
20
21 string UnicodeIntegerToUTF8(integer input)//Mono Safe, LSO Safe
22 {
23 integer bytes = llCeil(llLog(input) / 0.69314718055994530941723212145818);
24 bytes = (input >= 0x80) * (bytes + ~(((1 << bytes) - input) > 0)) / 5;//adjust
25 string result = "%" + byte2hex((input >> (6 * bytes)) | ((0x3F80 >> bytes) << !bytes));
26 while(bytes)
27 result += "%" + byte2hex((((input >> (6 * (bytes = ~-bytes))) | 0x80) & 0xBF));
28 return llUnescapeURL(result);
29 }
30
31 string byte2hex(integer x)//Mono Safe, LSO Safe
32 {//Helper function for use with unicode characters.
33 integer y = (x >> 4) & 0xF;
34 return llGetSubString(hexc, y, y) + llGetSubString(hexc, x & 0xF, x & 0xF);
35 }//This function would benifit greatly from the DUP opcode, it would remove 19 bytes.
36
37 string hexc="0123456789ABCDEF";
38
39 //} Combined Library
40 KeySetup(string password, string nonce)
41 {
42 //All addition is done modulous
43 list WholePassword;
44 list statePartOne = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75];
45 list statePartTwo = [76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150];
46 list statePartThree = [151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225];
47 list statePartFour = [226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255];
48 theState = statePartOne + statePartTwo + statePartThree + statePartFour;
49 statePartOne = [];
50 statePartTwo = [];
51 statePartThree = [];
52 statePartFour = [];
53 integer swapper;
54 //setup the plaintext list
55 integer ThePerpetualMax;
56 //setup the password. Use i since we already have it.
57 ThePerpetualMax = llStringLength(password);
58 for(i = 0; i < ThePerpetualMax; i++)
59 {
60 WholePassword = (WholePassword = []) + WholePassword + [UTF8ToUnicodeInteger(llGetSubString(password,i,i))];
61 }
62 ThePerpetualMax = llStringLength(nonce);
63 for(i = 0; i < ThePerpetualMax; i++)
64 {
65 WholePassword = (WholePassword = []) + WholePassword + [UTF8ToUnicodeInteger(llGetSubString(nonce,i,i))];
66 }
67 //Now WholePassword is equal to a list of the ASCII values of the password + the nonce
68 i=0;
69 j=0;
70 //mix init, this sets up the ARCFOUR PRNG
71 ThePerpetualMax = llGetListLength(WholePassword);
72 for(i=0 ; i < 256; i++)
73 {
74 //Mix step one
75 //Add to the variable j the contents of the ith element of the state array and the nth element of the key, where n is equal to i modulo the length of the key.
76 j = (j + llList2Integer(theState, i) + llList2Integer(WholePassword,i % ThePerpetualMax)) % 256;
77 //Mix step two. Swap the ith element and the jth element of the state array
78 swapper = llList2Integer(theState, i);
79 theState=llListReplaceList(theState, [llList2Integer(theState,j)] ,i,i);
80 theState=llListReplaceList(theState, [swapper],j,j);
81 }
82 i=0;
83 j=0;
84 //Key setup is complete!
85
86 }
87 string EncryptText(string plaintext)
88 //This does not repeat key setup, but continues with the same state array and values for i and j
89 {
90 //All addition is done modulous
91 string Output;
92 list PlaintextBytes;
93 list CipheredBytes;
94 integer n;
95 integer counter;
96 integer swapper;
97 integer ByteToAdd;
98 //setup the plaintext list
99 integer ThePerpetualMax;
100 ThePerpetualMax = llStringLength(plaintext);
101 for(counter = 0; counter < ThePerpetualMax; counter++)
102 {
103 PlaintextBytes = (PlaintextBytes = []) + PlaintextBytes + [UTF8ToUnicodeInteger(llGetSubString(plaintext,counter,counter))];
104
105 }
106 ThePerpetualMax = llGetListLength(PlaintextBytes);
107 for(counter=0;counter < ThePerpetualMax;counter++)
108 {
109 //The variable i is incremented by one
110 i = (i + 1) % 256;
111 //The contents of the ith element of the state array is then added to j
112 j = (j + llList2Integer(theState, i)) % 256;
113 //The ith and jth elements of the state array are swapped and their contents are added together to form a new value n.
114 swapper = llList2Integer(theState, i);
115 theState=llListReplaceList(theState, [llList2Integer(theState,j)] ,i,i);
116 theState=llListReplaceList(theState, [swapper],j,j);
117 n = (llList2Integer(theState, i) + llList2Integer(theState, j)) % 256;
118 //The nth element of the state array is then combined with the message byte, using a bit by bit exclusive-or operation, to form the output byte.
119 ByteToAdd = llList2Integer(theState, n) ^ llList2Integer(PlaintextBytes, counter);
120 CipheredBytes = (CipheredBytes = []) + CipheredBytes + [ByteToAdd];
121 }
122
123
124 return llList2CSV(CipheredBytes);
125 }
126 default
127 {
128
129 touch_start(integer total_number)
130 {
131 llSay(0, "Key is 'Key', plaintext is 'Plaintext'. Output:");
132 KeySetup("Key","");
133 llSay(0,"Key setup complete. Encrypting now...");
134 llSay(0,EncryptText("Plaintext"));
135 //will output 187, 243, 22, 232, 217, 64, 175, 10, 211
136 }
137 }

Back to the Best Free Tools in Second Life and OpenSim.