<script language="JavaScript" type="text/javascript">

function sifrovani()
{
	var to_enc = document.forms['the_form'].elements["str"].value;

	var klic=document.forms['the_form'].elements.klic.value
	var the_res="";//the result will be here
	for(i=0;i<to_enc.length;++i)
	{
		the_res+=String.fromCharCode(klic^to_enc.charCodeAt(i));
	}
	document.forms['the_form'].elements.res.value=the_res;
}

function desifrovani()
{
	var to_dec=document.forms['the_form'].elements.res.value
	document.forms['the_form'].elements.dec_res.value="";

	var klic=document.forms['the_form'].elements.klic.value
	for(i=0;i<to_dec.length;i++)
	{
		document.forms['the_form'].elements.dec_res.value+=String.fromCharCode(klic^to_dec.charCodeAt(i));
	}
}
</script>

<form name="the_form">
<table>
<tr><td colspan="3">XOR Key: <input type="text" name="klic" size="4"></td></tr>
<tr><td nowrap>String to encrypt: <input type="text" name="str" size="16"></td><td colspan="2"><input type="button" onClick="sifrovani()" value="Encrypt"></td></tr>
<tr><td nowrap>Encrypted string:&nbsp;&nbsp;<input type="text" name="res" size="16"></td><td><input type="button" onClick="desifrovani()" value="Decrypt"></td><td><input type="text" name="dec_res" size="16"></td></tr>
</table>
</form