From af87286cb2b886ee04940e065d4e6c8e9b1e9f1d Mon Sep 17 00:00:00 2001 From: JMRaich Date: Sat, 21 May 2022 14:38:46 +0200 Subject: [PATCH] Added CoffeeScript --- CoffeeScript/XOREncryption.coffee | 16 ++++++++++++++++ README.md | 1 + 2 files changed, 17 insertions(+) create mode 100644 CoffeeScript/XOREncryption.coffee diff --git a/CoffeeScript/XOREncryption.coffee b/CoffeeScript/XOREncryption.coffee new file mode 100644 index 0000000..217202e --- /dev/null +++ b/CoffeeScript/XOREncryption.coffee @@ -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) \ No newline at end of file diff --git a/README.md b/README.md index 61de381..7354fa0 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Simple implementation of XOR Encryption/Decrypting in various languages, includi - [Groovy](Groovy/XOREncryption.groovy) - [Java \(Android Compatible\)](Java%20\(Android%20compatible\)/XOREncryption.java) - [JavaScript \(Node.js Compatible\)](JavaScript/XOREncryption.js) +- [CoffeeScript](CoffeeScript/XOREncryption.coffee) - [Kotlin](Kotlin/XOREncryption.kt) - [Objective-C](Objective-C/main.m) - [PHP](PHP/XOREncryption.php)