Пример #1
0
        //get inverse of encryption key for decryption
        static GeneralMatrix GetInverse(GeneralMatrix key)
        {
            GeneralMatrix invKey = key.Inverse();
            //calculate determinant to the power of 30
            double det = key.Determinant();
            double zDet = Math.Pow(det, 30);

            //multiply each value by det^30 and mod31 that value
            for (int i = 0; i < invKey.RowDimension; i++)
            {
                for (int j = 0; j < invKey.ColumnDimension; j++)
                {
                    var temp = (invKey.GetElement(i, j) * zDet) % 31;
                    invKey.SetElement(i, j, temp);
                }
            }
            Console.WriteLine("3x3 decryption matrix successfully created from key.txt");
            return invKey;
        }