diff --git a/C#/Main.cs b/C#/Main.cs new file mode 100644 index 0000000..376cb0b --- /dev/null +++ b/C#/Main.cs @@ -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); + } +} diff --git a/README.md b/README.md index 83d96e4..8932a74 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ XOR Encryption Simple implementation of XOR Encryption/Decrypting in various languages, including: - [C](C/main.c) +- [C#](C#/Main.cs) - [C++](C++/main.cpp) - [Dart](Dart/xorencryption.dart) - [Groovy](Groovy/XOREncryption.groovy)