var key = 0x75; for (var i = 0; i < unEncrypted.length; i++) { encrypted += String.fromCharCode(unEncrypted.charCodeAt(i) ^ key); console.log(encrypted); var str = ''; for (var i = 0; i < encrypted.length; i++) { str += (String.fromCharCode(encrypted.charCodeAt(i) ^ key)); console.log(str);