|
Aidenet.com Aide informatique et nouvelles technologies
|
|||||||||||||||||||||||||||||||
Forum d'entraide sur l'informatique et les nouvelles technologies
Vous n'êtes pas identifié.
Bonjours j'ai une fonction qui cripte une chaine mais je n'arrive pas à comprendre comment c'est fais pouvez vous m'aider et si possible me dire comment creer une page qui cripte les infos que je veux merci
function crypte(texte)
{
trace("en clair : " + texte);
if (typeof texte == "number")
{
texte = new String(texte);
}
alphabet = 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");
cle = new Array();
i = 0;
while (i < 10)
{
secu = 0;
while (secu == 0)
{
temp = Math.floor(Math.random() * alphabet.length);
lettre = alphabet[temp];
secu = 1;
j = 0;
while (j < cle.length)
{
if (lettre == cle[j])
{
secu = 0;
}
++j;
}
}
cle.push(lettre);
++i;
}
trace("clé : " + cle.join(""));
code = new Array();
i = 0;
while (i < texte.length)
{
code.push(cle[texte.substr(i, 1)]);
++i;
}
trace("encodé : " + code.join(""));
lemot = "";
i = 0;
while (i < texte.length)
{
lemot = lemot + code[i];
lemot = lemot + cle[i];
++i;
}
lacle = cle.join("");
lemot = lemot + lacle.substr(texte.length, lacle.length - texte.length);
trace("crypté : " + lemot);
return lemot;
}
this.stop();
route.stop();
gotoAndStop(1);
Hors ligne
|
|
|
|