Beispiel #1
0
        public void MatrixIntGF26Test()
        {
            int time = 100;

            for (int i = 0; i < time; i++)
            {
                var matrix  = new MatrixIntGF26(RandomHelper.GetHillMatrix());
                var inverse = matrix.Inverse();
                var multify = matrix.MultifyMod(inverse);
                Assert.IsTrue(multify.IsUnit());
            }
        }
Beispiel #2
0
        public void HillCipherTest()
        {
            // 这个矩阵有问题,//后来发现是不能求逆
            int[,] ekey = new int[, ] {
                { 10, 05, 07, 02, 08, 21, 09, 16, 24 },
                { 23, 02, 11, 16, 16, 04, 15, 09, 23 },
                { 07, 07, 01, 19, 04, 04, 20, 23, 20 },
                { 19, 16, 21, 05, 02, 02, 18, 20, 15 },
                { 12, 24, 05, 19, 20, 08, 14, 14, 07 },
                { 13, 03, 16, 04, 04, 02, 03, 21, 14 },
                { 18, 15, 02, 04, 07, 10, 01, 15, 24 },
                { 04, 19, 01, 09, 23, 21, 13, 04, 09 },
                { 18, 12, 11, 18, 05, 14, 22, 08, 21 }
            };

            var mat = new MatrixIntGF26(ekey);
            var inv = mat.Inverse();
            var mul = mat.MultifyMod(inv);
        }