Enigma, cryptage des message en javascript

<html>
<head>
<title>INEGMA</title>
<script language= "JavaScript">
<!--
var messagecd=""
function codage(){var message = document.machine.msg.value
message=message.toUpperCase()
var code = document.machine.codex.value
for(j=0; j<code; j++)
{messagecd=""
for(i=0; i<message.length; i++) {
switch(message.charAt(i)){
case " " :
messagecd= messagecd+" ";
break;
case "A" :
messagecd= messagecd+"E";
break;
case "B" :
messagecd= messagecd+"P";
break;
case "C" :
messagecd= messagecd+"S";
break;
case "D" :
messagecd= messagecd+"T";
break;
case "E" :
messagecd= messagecd+"I";
break;
case "F" :
messagecd= messagecd+"W";
break;
case "G" :
messagecd= messagecd+"K";
break;
case "H" :
messagecd= messagecd+"N";
break;
case "I" :
messagecd= messagecd+"U";
break;
case "J" :
messagecd= messagecd+"V";
break;
case "K" :
messagecd= messagecd+"G";
break;
case "L" :
messagecd= messagecd+"C";
break;
case "M" :
messagecd= messagecd+"L";
break;
case "N" :
messagecd= messagecd+"R";
break;
case "O" :
messagecd= messagecd+"Y";
break;
case "P" :
messagecd= messagecd+"B";
break;
case "Q" :
messagecd= messagecd+"X";
break;
case "R" :
messagecd= messagecd+"H";
break;
case "S" :
messagecd= messagecd+"M";
break;
case "T" :
messagecd= messagecd+"D";
break;
case "U" :
messagecd= messagecd+"O";
break;
case "V" :
messagecd= messagecd+"F";
break;
case "W" :
messagecd= messagecd+"Z";
break;
case "X" :
messagecd= messagecd+"Q";
break;
case "Y" :
messagecd= messagecd+"A";
break;
case "Z" :
messagecd= messagecd+"J";
break;
default :
messagecd= messagecd+message.charAt(i);
}
}
message=messagecd
}
==machine.msgcd.value = messagecd==
}
var messagecd=""
function decodage(){
var message = document.machine.msg.value
var messagecd=""
message=message.toUpperCase()
var code = document.machine.codex.value
for(j=0; j<code; j++)
{messagecd=""
for(i=0; i<message.length; i++) {
switch(message.charAt(i)){
case " " :
messagecd= messagecd+" ";
break;
case "A" :
messagecd= messagecd+"Y";
break;
case "B" :
messagecd= messagecd+"P";
break;
case "C" :
messagecd= messagecd+"L";
break;
case "D" :
messagecd= messagecd+"T";
break;
case "E" :
messagecd= messagecd+"A";
break;
case "F" :
messagecd= messagecd+"V";
break;
case "G" :
messagecd= messagecd+"K";
break;
case "H" :
messagecd= messagecd+"R";
break;
case "I" :
messagecd= messagecd+"E";
break;
case "J" :
messagecd= messagecd+"Z";
break;
case "K" :
messagecd= messagecd+"G";
break;
case "L" :
messagecd= messagecd+"M";
break;
case "M" :
messagecd= messagecd+"S";
break;
case "N" :
messagecd= messagecd+"H";
break;
case "O" :
messagecd= messagecd+"U";
break;
case "P" :
messagecd= messagecd+"B";
break;
case "Q" :
messagecd= messagecd+"X";
break;
case "R" :
messagecd= messagecd+"N";
break;
case "S" :
messagecd= messagecd+"C";
break;
case "T" :
messagecd= messagecd+"D";
break;
case "U" :
messagecd= messagecd+"I";
break;
case "V" :
messagecd= messagecd+"J";
break;
case "W" :
messagecd= messagecd+"F";
break;
case "X" :
messagecd= messagecd+"Q";
break;
case "Y" :
messagecd= messagecd+"O";
break;
case "Z" :
messagecd= messagecd+"W";
break;
default :
messagecd= messagecd+message.charAt(i);
}
}
message=messagecd
}
==machine.msgcd.value = messagecd==
}
//-->
</script>
</head>
<body>
Machine INEGMA <sup>version
BETA</sup>
<form method ="post" action="" name="machine">
<textarea name="msg" cols="50" wrap="PHYSICAL" rows="3"></textarea>
Code de criptage :
<textarea name="msgcd" cols="50" rows="3"></textarea>
</form>
</body>
</html>

Rejoignez-nous