public void Unigraph_HillTest() { Hill hill = new Hill(Utility.EnglishAlphabet());// Utility.KeyedEnglishAlphabet("KRYPTOS")); hill.Key = new Matrix(new double[, ] { { 6, 24, 1 }, { 13, 16, 10 }, { 20, 17, 15 } }); //hill.Key = new double[,] { { 2, 4, 5 }, { 9, 2, 1 }, { 3, 17, 7 } }; //hill.Key = new double[,] { { 5, 17 }, { 4, 15 } }; cipher = ""; clear = ""; generated = ""; for (int i = 0; i < 25; i++) { generated = hill.GenerateRandomString(552); while (generated.Length % hill.Key.Rows != 0) { generated += 'Z'; } //generated = "ABCDEFGHI"; cipher = hill.Encrypt(generated); clear = hill.Decrypt(cipher); int x = generated.Length; int y = cipher.Length; int z = clear.Length; Assert.AreEqual(generated, clear); } }
public void BasicEncryptTest() { var key = new int[][] { new int[] { 2, 4, 5 }, new int[] { 9, 2, 1 }, new int[] { 3, 17, 7 } }; Hill h = new Hill(key); var encrypted = h.Encrypt("ATT"); Assert.AreEqual("PFO", encrypted); }