mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
Added C# implementation
This commit is contained in:
parent
3a2d52edb8
commit
279a6d5c6d
24
C#/Main.cs
Normal file
24
C#/Main.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
class XOREncryption
|
||||||
|
{
|
||||||
|
private static string encryptDecrypt(string input) {
|
||||||
|
char[] key = {'K', 'C', 'Q'};
|
||||||
|
char[] output = new char[input.Length];
|
||||||
|
|
||||||
|
for(int i = 0; i < input.Length; i++) {
|
||||||
|
output[i] = (char) (input[i] ^ key[i % key.Length]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new string(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Main (string[] args)
|
||||||
|
{
|
||||||
|
string encrypted = encryptDecrypt("kylewbanks.com");
|
||||||
|
Console.WriteLine ("Encrypted:" + encrypted);
|
||||||
|
|
||||||
|
string decrypted = encryptDecrypt(encrypted);
|
||||||
|
Console.WriteLine ("Decrypted:" + decrypted);
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ XOR Encryption
|
|||||||
Simple implementation of XOR Encryption/Decrypting in various languages, including:
|
Simple implementation of XOR Encryption/Decrypting in various languages, including:
|
||||||
|
|
||||||
- [C](C/main.c)
|
- [C](C/main.c)
|
||||||
|
- [C#](C#/Main.cs)
|
||||||
- [C++](C++/main.cpp)
|
- [C++](C++/main.cpp)
|
||||||
- [Dart](Dart/xorencryption.dart)
|
- [Dart](Dart/xorencryption.dart)
|
||||||
- [Groovy](Groovy/XOREncryption.groovy)
|
- [Groovy](Groovy/XOREncryption.groovy)
|
||||||
|
Loading…
Reference in New Issue
Block a user