static void Main(string[] args) { HillCipher hill = new HillCipher(26); Console.WriteLine("Write message, please"); var encodedMessage = hill.Encode(Console.ReadLine()); Console.WriteLine($"Key: {hill.GetKey}"); Console.WriteLine($"Encoded message:\n{encodedMessage}"); var decodedMessage = hill.Decode(encodedMessage); Console.WriteLine($"Decoded message:\n{decodedMessage}"); Console.ReadKey(); }
public void Decode_MessageInEnglishAndKey_ReturnsMessageDecodedForEnglishAlphabetAndProvidedKey(string message, string expectedDecodedMessage, object[] key) { var flattenedKey = (int[])key[0]; int[,] keyTransformed = new int[2, 2] { { flattenedKey[0], flattenedKey[1] }, { flattenedKey[2], flattenedKey[3] } }; HillCipher encoder = new HillCipher(keyTransformed, new EnglishAlphabet()); string encodedMessage = encoder.Decode(message); Assert.Equal(expectedDecodedMessage, encodedMessage); }