Salve, girando per il web ho trovato questi 2 codici che permettono di codificare un testo in base alla chiava data,

credo che in pratica funzioni cosi

a ogni lettere viene associato un valore

a = 1
b = 2
c = 3
ecc ecc
e la chiave vine sommata a questo valore

se per esempio quindi io scrivo a a a e metto chiave 1 verrà fuori b b b non sò se mi sono spiegato bene.

i codici sono questi

codice:
<script language='javascript'>





// prelevato e spiegato su http://www.web-link.it

<!-- Begin
var wt = ""; //temporary holder
var et = ""; //encoded text
var all = "";
var all2 = "";
var alpha2 = "abcdefghijklmnopqrstuvwxyz";
var a = "a"; var b = "b"; var c = "c"; var d = "d";
var e = "e"; var f = "f"; var g = "g"; var h = "h";
var i = "i"; var j = "j"; var k = "k"; var l = "l";
var m = "m"; var n = "n"; var o = "o"; var p = "p";
var q = "q"; var r = "r"; var s = "s"; var t = "t";
var u = "u"; var v = "v"; var w = "w"; var x = "x";
var y = "y"; var z = "z";
var alpha = new Array('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');

function encode() {
wt = "";
et = "";
all = "";
var theText = document.f1.ta1.value.toLowerCase();
var num = document.f1.tb1.value;
i2 = 0;
for (i = 0; i < num; i++) { 
i2 = i2 + 1;
if (i2 == 26) i2 = 0;
}
a = alpha[i2]; i2 = next(i2);
b = alpha[i2]; i2 = next(i2);
c = alpha[i2]; i2 = next(i2);
d = alpha[i2]; i2 = next(i2);
e = alpha[i2]; i2 = next(i2);
f = alpha[i2]; i2 = next(i2);
g = alpha[i2]; i2 = next(i2);
h = alpha[i2]; i2 = next(i2);
i = alpha[i2]; i2 = next(i2);
j = alpha[i2]; i2 = next(i2);
k = alpha[i2]; i2 = next(i2);
l = alpha[i2]; i2 = next(i2);
m = alpha[i2]; i2 = next(i2);
n = alpha[i2]; i2 = next(i2);
o = alpha[i2]; i2 = next(i2);
p = alpha[i2]; i2 = next(i2);
q = alpha[i2]; i2 = next(i2);
r = alpha[i2]; i2 = next(i2);
s = alpha[i2]; i2 = next(i2);
t = alpha[i2]; i2 = next(i2);
u = alpha[i2]; i2 = next(i2);
v = alpha[i2]; i2 = next(i2);
w = alpha[i2]; i2 = next(i2);
x = alpha[i2]; i2 = next(i2);
y = alpha[i2]; i2 = next(i2);
z = alpha[i2]; i2 = next(i2);
var all = 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;
all = all.split("");
encode2(all);
}
function next(x) {
if (x == 25) x = -1;
x = x + 1;
return x;
}
function encode2(all2) {
var temp2 = document.f1.ta1.value.toLowerCase();
temp2 = temp2.split("");
var q = 0;
while (q < temp2.length) { 
wt = temp2[q];
var where = alpha2.indexOf(wt);
if (where == -1) { et += wt; }
if (where != -1) { et += all2[where]; }
q = q + 1;
}
document.f1.ta1.value = et;
}
function decode() {
wt = "";
et = "";
all = "";
all3 = "";
var theText = document.f1.ta1.value.toLowerCase();
var num = document.f1.tb1.value;
i2 = 0;
for (i = 0; i < num; i++) {
i2 = i2 + 1;
if (i2 == 26) i2 = 0;
}
a = alpha[i2]; i2 = next(i2);
b = alpha[i2]; i2 = next(i2);
c = alpha[i2]; i2 = next(i2);
d = alpha[i2]; i2 = next(i2);
e = alpha[i2]; i2 = next(i2);
f = alpha[i2]; i2 = next(i2);
g = alpha[i2]; i2 = next(i2);
h = alpha[i2]; i2 = next(i2);
i = alpha[i2]; i2 = next(i2);
j = alpha[i2]; i2 = next(i2);
k = alpha[i2]; i2 = next(i2);
l = alpha[i2]; i2 = next(i2);
m = alpha[i2]; i2 = next(i2);
n = alpha[i2]; i2 = next(i2);
o = alpha[i2]; i2 = next(i2);
p = alpha[i2]; i2 = next(i2);
q = alpha[i2]; i2 = next(i2);
r = alpha[i2]; i2 = next(i2);
s = alpha[i2]; i2 = next(i2);
t = alpha[i2]; i2 = next(i2);
u = alpha[i2]; i2 = next(i2);
v = alpha[i2]; i2 = next(i2);
w = alpha[i2]; i2 = next(i2);
x = alpha[i2]; i2 = next(i2);
y = alpha[i2]; i2 = next(i2);
z = alpha[i2]; i2 = next(i2);
var all = 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;
all3 = all;
all = all.split("");
decode2(all3);
}
function decode2(all2) { 
var alpha2 = "abcdefghijklmnopqrstuvwxyz";
alpha2 = alpha2.split("");
var temp2 = document.f1.ta1.value.toLowerCase();
temp2 = temp2.split("");
var v = 0;
while (v < temp2.length) {
wt = temp2[v];
var where = all2.indexOf(wt);
if (where == -1) { et += wt; }
if (where != -1) { et += alpha2[where]; }
v = v + 1;
}
document.f1.ta1.value = et;
}
//  End -->
</script>
codice:
<div align="center"><form name=f1>
<textarea name=ta1 cols=40 rows=20>
</textarea>



Valore Chiave:  <input type="text" size=10 name="tb1" value="">


<input type="button" value="Codifica Messaggio" onClick="encode(); return false;">
<input type="button" value="Decodifica Messaggio" onClick="decode(); return false;">
</form></div>
Io sono molto inesperto nel campo, mi potreste spiegare passo passo come utilizzare questi codici per creare un codificatore?