The CryptoJS URL (https://code.google.com/p/crypto-js/) contains a collection of secure cryptographic algorithms written in Javascript.
encode, pass in the control
var ckey = $("#cryptonkey").val();
var y=document.getElementById(control).value;
var encrypted = CryptoJS.AES.encrypt(y, ckey);
document.getElementById("crypton").value=encrypted;
decode, pass in the control
var ckey = $("#cryptonkey").val();
var y=document.getElementById(control).value;
var decrypted = CryptoJS.AES.decrypt(y, ckey);
decrypted = decrypted.toString(CryptoJS.enc.Utf8);
document.getElementById("cryptoff").value=decrypted;
If you receive a secret message and know the secret key, you can enter the secret key and place your secret message into the "crypt-on" box. The secret message will be visible to you in the "crypt-off" box.