//Here is the JavaScript code that you are looking for:
function xor_str()
{
 var to_enc = document.forms['the_form'].elements["str"].value;

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

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

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