- Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathXOREncryption.js
More file actions
Latest commit
17 lines (13 loc) · 481 Bytes
/
Copy pathXOREncryption.js
File metadata and controls
17 lines (13 loc) · 481 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
functionencryptDecrypt(input){
varkey=['K','C','Q'];//Can be any chars, and any size array
varoutput=[];
for(vari=0;i<input.length;i++){
varcharCode=input.charCodeAt(i)^key[i%key.length].charCodeAt(0);
output.push(String.fromCharCode(charCode));
}
returnoutput.join("");
}
varencrypted=encryptDecrypt("kylewbanks.com");
console.log("Encrypted:"+encrypted);
vardecrypted=encryptDecrypt(encrypted);
console.log("Decrypted:"+decrypted);