我有一个制作凯撒密码的项目。我被困在 textBox2.text 中,即它没有显示加密的文本。
请检查我的代码和指南,我将非常感谢!
请告诉我我的代码中是否还有其他错误,那将非常好。
{
key = int.Parse(textBox3.Text) - 48;
// Input.ToLower();
int size = Input.Length;
char[] value = new char[size];
char[] cipher = new char[size];
for (int i = 0; i < size; i++)
{
value[i] = Convert.ToChar(Input.Substring(i, 1));
}
for (int re = 0; re < size; re++)
{
int count = 0;
int a = Convert.ToInt32(value[re]);
for (int y = 1; y <= key; y++)
{
if (count == 0)
{
if (a == 90)
{ a = 64; }
else if (a == 122)
{ a = 96; }
cipher[re] = Convert.ToChar(a + y);
count++;
}
else
{
int b = Convert.ToInt32(cipher[re]);
if (b == 90)
{ b = 64; }
else if (b == 122)
{ b = 96; }
cipher[re] = Convert.ToChar(b + 1);
}
}
}
string ciphertext = "";
for (int p = 0; p < size; p++)
{
ciphertext = ciphertext + cipher[p].ToString();
}
ciphertext.ToUpper();
textBox2.Text = ciphertext;
}