prova a copiare ed incollare
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="it" xml:lang="it">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
var Cifrario = function() {
var _alfabeto = {
/* vocali (originale:cifrato) */
"a" : "e", "e" : "i", "i" : "o", "o" : "u",
"u" : "a",
/* consonanti (originale:cifrato) */
"b" : "c", "c" : "d", "d" : "f", "f" : "g",
"g" : "h", "h" : "j", "j" : "k", "k" : "l",
"l" : "m", "m" : "n", "n" : "p", "p" : "q",
"q" : "r", "r" : "s", "s" : "t", "t" : "v",
"v" : "w", "w" : "x", "x" : "y", "y" : "z",
"z" : "b"
};
return {
cifrazione : function(s) {
var input = new String(s);
var output = [];
for (var i=0; i<input.length; i++) {
output[output.length] = _alfabeto[input.charAt(i)];
}
return output.join('');
},
converti : function(i, o) {
document.getElementById(o).value = this.cifrazione(document.getElementById(i).value.toLowerCase());
}
}
}
var miocifrario = new Cifrario();
</script>
</head>
<body>
<form>
<input type="password" id="originale1" />
<input type="text" id="cifrato1" />
<input type="button" value="Cifra" onclick="miocifrario.converti('originale1', 'cifrato1');">
</form>
</body>
</html>