mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
Added CoffeeScript
This commit is contained in:
16
CoffeeScript/XOREncryption.coffee
Normal file
16
CoffeeScript/XOREncryption.coffee
Normal file
@@ -0,0 +1,16 @@
|
||||
encryptDecrypt = (input) ->
|
||||
key = ['K', 'C', 'Q'] #Can be any chars, and any size array
|
||||
output = ""
|
||||
|
||||
i = 0
|
||||
while i < input.length
|
||||
charCode = input.charCodeAt(i) ^ key[i % key.length].charCodeAt(0)
|
||||
output += String.fromCharCode charCode
|
||||
i++
|
||||
return output
|
||||
|
||||
encrypted = encryptDecrypt "kylewbanks.com"
|
||||
console.log("Encrypted:" + encrypted)
|
||||
|
||||
decrypted = encryptDecrypt encrypted
|
||||
console.log("Decrypted:" + decrypted)
|
||||
Reference in New Issue
Block a user