乘法密码加密算法

主要代码:

           

 int i,j,k,b;
            char[] str1 = new char[80];
            Console.WriteLine("请输入需要加密的明文:");
            string str = Console.ReadLine();
            int[] t1 = {3,5,7,9,11,15,17,19,21,23,25};
            char[] t2 = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
            for (i = 0;i < t1.Length;i++)
            {
                Console.WriteLine("{0}", t1[i]);
            }
            Console.WriteLine("选择加密的系数:");
            j = int.Parse(Console.ReadLine());

            for (int m = 0; m < str.Length;m++ )
            {
                for (k = 0; k < t2.Length; k++)
                {
                    if (str[m] == t2[k])
                    {
                        b = (j * k) % 26;
                        str1[m] = t2[b];
                    }
                }
            }
            Console.WriteLine("加密所得的密文如下:");
            Console.WriteLine(str1);
            Console.ReadKey();

 

 

 

 

 

 

 

 

乘法密码加密算法_第1张图片

你可能感兴趣的:(乘法密码加密算法)