public void Hill_CipherTest() { string msg = "HELLOWORLD"; Cipher cipher = new Hill_Cipher(msg, "CDFH"); Assert.IsNotNull(cipher); cipher = null; Assert.IsNull(cipher); cipher = new Hill_Cipher(msg, "CDFH"); Assert.IsNotNull(cipher); // Check conversion with 2x2 matrix cipher.Message = cipher.Encrypt(); string actual = cipher.Decrypt(); Assert.AreEqual(msg, actual, true); cipher.Message = "Hello World I am William"; string expected = "HELLOWORLDIAMWILLIAM"; cipher.Message = cipher.Encrypt(); Console.WriteLine(cipher.Message); actual = cipher.Decrypt(); Assert.AreEqual(expected, actual, true); // Check conversion with 3x3 matrix /*msg = "Hello Will the hill cipher now works!"; * cipher = new Hill_Cipher(msg, "BAAABAAAB"); * cipher.Message = cipher.Encrypt(); * string actual = cipher.Decrypt(); * expected = "hellowillthehillciphernowworks"; * Assert.AreEqual(expected, actual, true);*/ }
public void DecryptTest() { Cipher cipher = new Hill_Cipher("MDLNFN", "CDFH"); string expected = cipher.Decrypt(); string actual = "DCODEZ"; Assert.AreEqual(expected, actual); }