Created
May 2, 2018 13:02
-
-
Save wellingtonpgp/6bdf5c73414f51cf4b33f6544a61d0e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function encryptDecrypt(input) { | |
| var key = ['K', 'C', 'Q']; //Can be any chars, and any size array | |
| var output = []; | |
| for (var i = 0; i < input.length; i++) { | |
| var charCode = input.charCodeAt(i) ^ key[i % key.length].charCodeAt(0); | |
| output.push(String.fromCharCode(charCode)); | |
| } | |
| return output.join(""); | |
| } | |
| var encrypted = encryptDecrypt("kylewbanks.com"); | |
| console.log("Encrypted:"+encrypted); | |
| var decrypted = encryptDecrypt(encrypted); | |
| console.log("Decrypted:"+decrypted); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment