static void Main(string[] args) { Console.WriteLine("AUTOKEY CIPHER\n"); AutoKey.Encrypt(); AutoKey.Decrypt(); Console.WriteLine("PORTA CIPHER\n"); Porta.Decrypt("GOIINDUGAFYBXJQOFBNUYNXJWHRCBINZOLNSNJPJVGYSETY", "BONUSMARKS"); Porta.Encrypt("THOSEWHOSOLVETHISWILLGETANEXTRAFIVEMARKSINFINAL", "BONUSMARKS"); Console.ReadKey(); }
public static void Encrypt(string plainText, string Key) { plainText = plainText.Replace(" ", string.Empty).ToUpper(); char[] plainTextArray = plainText.ToCharArray(); char[] KeyArray = Porta.KeyStream(plainTextArray, Key.ToCharArray()); string cipherText = ""; for (int i = 0; i < plainText.Length; i++) { int index = Cipher.GetAlphabetValue(plainTextArray[i]); cipherText += Cipher.GetPortaValue(index, KeyArray[i]); } Console.WriteLine("Encrypted Text: " + cipherText); }