diff --git a/Groovy/XOREncryption.groovy b/Groovy/XOREncryption.groovy new file mode 100644 index 0000000..58db625 --- /dev/null +++ b/Groovy/XOREncryption.groovy @@ -0,0 +1,19 @@ +def encryptDecrypt(String input) { + def key = ['K', 'C', 'Q'] //Can be any chars, and any length array + def output = [] + + for(int i = 0; i < input.length(); i++) { + int a = input.charAt(i) as int; + int b = (key[i % key.size()] as char) as int + output.add((a ^ b) as char) + } + + output.join("") +} + + +def encrypted = encryptDecrypt("kylewbanks.com") +println("Encrypted:" + encrypted) + +def decrypted = encryptDecrypt(encrypted) +println("Decrypted:" + decrypted) \ No newline at end of file diff --git a/README.md b/README.md index e85dbb7..d99a083 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Simple implementation of XOR Encryption/Decrypting in various languages, includi - [C](C/main.c) - [C++](C++/main.cpp) +- [Groovy](Groovy/XOREncryption.groovy) - [Java](Java (Android compatible\)/XOREncryption.java) - [JavaScript](JavaScript/XOREncryption.js) - [Objective-C](Objective-C/main.m)