凯撒加密算法简化

      明文:小写字母      密文:大写字母

     凯撒算法:移位    

 

          Console.WriteLine("请输入需要加密的明文:");
            string m = Console.ReadLine();
            char[] str=new char[80];
            char[] t1 = {'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'};
            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'};
            int i,b;
          
            for (i = 0; i < m.Length;i++ )
            {
                for(int j=0;j                 {
                if (m[i] == t2[j])
                {
                    b = ((j + 3))%26;
                    str[i] = t1[b];
                }
               
            }
            }
             
               Console.WriteLine("凯撒密码加密所得的密文为:");
               Console.WriteLine(str);

               Console.ReadLine();

你可能感兴趣的:(凯撒加密算法简化)