三生万物。
<!DOCTYPE html>
<html>
<head>
<!-- ---------------------------------------------------------------------- -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript XOR Encryption</title>
<!-- ---------------------------------------------------------------------- -->
<script type="text/javascript">
function xor()
{
var input = document.forms['the_form'].elements.input.value;
var key = document.forms['the_form'].elements.key.value
var output = ""
for(i=0; i<input.length; ++i)
{
output += String.fromCharCode(key ^ input.charCodeAt(i));
}
document.forms['the_form'].elements.output.value = output;
}
</script>
<!-- ---------------------------------------------------------------------- -->
</head>
<body>
<!-- ---------------------------------------------------------------------- -->
<form name="the_form">
<table>
<tr>かぎ: <input type="text" name="key" value="3"></tr><br />
<br />
<tr>輸入:</tr><br />
<br />
<tr><textarea type="text" name="input" rows="8" cols="25"></textarea></tr><br />
<br />
<tr><input type="button" onClick="xor()" value="暗号化"></tr><br />
<br />
<tr>輸出:</tr><br />
<br />
<tr><textarea type="text" name="output" rows="8" cols="25"></textarea></tr><br />
<br />
</table>
</form>
<!-- ---------------------------------------------------------------------- -->
</body>
</html>