u012182604的專欄
主要程式碼:
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();