mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
Added Groovy implementation
This commit is contained in:
parent
b0fc8ff6b9
commit
4d64b1eacd
19
Groovy/XOREncryption.groovy
Normal file
19
Groovy/XOREncryption.groovy
Normal file
@ -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)
|
@ -5,6 +5,7 @@ Simple implementation of XOR Encryption/Decrypting in various languages, includi
|
|||||||
|
|
||||||
- [C](C/main.c)
|
- [C](C/main.c)
|
||||||
- [C++](C++/main.cpp)
|
- [C++](C++/main.cpp)
|
||||||
|
- [Groovy](Groovy/XOREncryption.groovy)
|
||||||
- [Java](Java (Android compatible\)/XOREncryption.java)
|
- [Java](Java (Android compatible\)/XOREncryption.java)
|
||||||
- [JavaScript](JavaScript/XOREncryption.js)
|
- [JavaScript](JavaScript/XOREncryption.js)
|
||||||
- [Objective-C](Objective-C/main.m)
|
- [Objective-C](Objective-C/main.m)
|
||||||
|
Loading…
Reference in New Issue
Block a user