mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
Added Dart implementation
This commit is contained in:
parent
4379fe3bc6
commit
3a2d52edb8
20
Dart/xorencryption.dart
Normal file
20
Dart/xorencryption.dart
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
String encryptDecrypt(String 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.codeUnitAt(i) ^ key[i % key.length].codeUnitAt(0);
|
||||
output.add(new String.fromCharCode(charCode));
|
||||
}
|
||||
|
||||
return output.join("");
|
||||
}
|
||||
|
||||
void main() {
|
||||
String encrypted = encryptDecrypt("kylewbanks.com");
|
||||
print("Encrypted:" + encrypted);
|
||||
|
||||
String decrypted = encryptDecrypt(encrypted);
|
||||
print("Decrypted:" + decrypted);
|
||||
}
|
@ -5,6 +5,7 @@ Simple implementation of XOR Encryption/Decrypting in various languages, includi
|
||||
|
||||
- [C](C/main.c)
|
||||
- [C++](C++/main.cpp)
|
||||
- [Dart](Dart/xorencryption.dart)
|
||||
- [Groovy](Groovy/XOREncryption.groovy)
|
||||
- [Java](Java (Android compatible\)/XOREncryption.java)
|
||||
- [JavaScript](JavaScript/XOREncryption.js)
|
||||
@ -13,6 +14,6 @@ Simple implementation of XOR Encryption/Decrypting in various languages, includi
|
||||
|
||||
This implementation goes beyond the basic single-key model to use multiple keys in a particular sequence, making it that much more difficult to brute-force.
|
||||
|
||||
In these examples, I'm encrypting the same string with the same keys in order to keep consistency with the output, and to demonstrate that an encrypted string from a C program will be decryptable in a Java application, etc.
|
||||
In these examples, I'm encrypting the same string with the same keys in order to keep consistency with the output, and to demonstrate that an encrypted string from a C program can be decrypted in a Java application, or any combination, so long as the keys remain the same.
|
||||
|
||||
For an in-depth explanation of the code, check out [KyleWBanks.com](http://kylewbanks.com/post/show/Simple-XOR-Encryption-Decryption-in-Cpp).
|
||||
|
Loading…
Reference in New Issue
Block a user