C#语言,一个简单的ACSII码转换程序、将明文转化为密文,将密文转化明文。
发布网友
发布时间:2022-04-29 17:27
我来回答
共1个回答
热心网友
时间:2023-10-23 15:54
private void btn1_Click(object sender, EventArgs e)
{
byte [] array = System.Text.Encoding.ASCII.GetBytes(txt1.Text.Trim());
byte[] byteArray = new byte[array.Length];
for (int i = 0; i < array.Length; i++)
{
int asciicode = (int)(array[i]);
asciicode = asciicode + 1;
byteArray[i]= asciicode ;
}
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
}
追问在语句第十行“byteArray[i]= asciicode ;”在VS中会报错。并且 我修改成byteArray[i] = Convert .ToByte (asciicode); 在TXT1中输入ABC 结果还是显示D
追答第十行改成下面的样子。
byteArray[i]= (byte)asciicode;
下面俩句一定要在for循环外
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
热心网友
时间:2023-10-23 15:54
private void btn1_Click(object sender, EventArgs e)
{
byte [] array = System.Text.Encoding.ASCII.GetBytes(txt1.Text.Trim());
byte[] byteArray = new byte[array.Length];
for (int i = 0; i < array.Length; i++)
{
int asciicode = (int)(array[i]);
asciicode = asciicode + 1;
byteArray[i]= asciicode ;
}
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
}
追问在语句第十行“byteArray[i]= asciicode ;”在VS中会报错。并且 我修改成byteArray[i] = Convert .ToByte (asciicode); 在TXT1中输入ABC 结果还是显示D
追答第十行改成下面的样子。
byteArray[i]= (byte)asciicode;
下面俩句一定要在for循环外
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
热心网友
时间:2023-10-23 15:54
private void btn1_Click(object sender, EventArgs e)
{
byte [] array = System.Text.Encoding.ASCII.GetBytes(txt1.Text.Trim());
byte[] byteArray = new byte[array.Length];
for (int i = 0; i < array.Length; i++)
{
int asciicode = (int)(array[i]);
asciicode = asciicode + 1;
byteArray[i]= asciicode ;
}
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
}
追问在语句第十行“byteArray[i]= asciicode ;”在VS中会报错。并且 我修改成byteArray[i] = Convert .ToByte (asciicode); 在TXT1中输入ABC 结果还是显示D
追答第十行改成下面的样子。
byteArray[i]= (byte)asciicode;
下面俩句一定要在for循环外
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
热心网友
时间:2023-10-23 15:54
private void btn1_Click(object sender, EventArgs e)
{
byte [] array = System.Text.Encoding.ASCII.GetBytes(txt1.Text.Trim());
byte[] byteArray = new byte[array.Length];
for (int i = 0; i < array.Length; i++)
{
int asciicode = (int)(array[i]);
asciicode = asciicode + 1;
byteArray[i]= asciicode ;
}
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
}
追问在语句第十行“byteArray[i]= asciicode ;”在VS中会报错。并且 我修改成byteArray[i] = Convert .ToByte (asciicode); 在TXT1中输入ABC 结果还是显示D
追答第十行改成下面的样子。
byteArray[i]= (byte)asciicode;
下面俩句一定要在for循环外
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
热心网友
时间:2023-10-23 15:54
private void btn1_Click(object sender, EventArgs e)
{
byte [] array = System.Text.Encoding.ASCII.GetBytes(txt1.Text.Trim());
byte[] byteArray = new byte[array.Length];
for (int i = 0; i < array.Length; i++)
{
int asciicode = (int)(array[i]);
asciicode = asciicode + 1;
byteArray[i]= asciicode ;
}
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
}
追问在语句第十行“byteArray[i]= asciicode ;”在VS中会报错。并且 我修改成byteArray[i] = Convert .ToByte (asciicode); 在TXT1中输入ABC 结果还是显示D
追答第十行改成下面的样子。
byteArray[i]= (byte)asciicode;
下面俩句一定要在for循环外
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
热心网友
时间:2023-10-23 15:54
private void btn1_Click(object sender, EventArgs e)
{
byte [] array = System.Text.Encoding.ASCII.GetBytes(txt1.Text.Trim());
byte[] byteArray = new byte[array.Length];
for (int i = 0; i < array.Length; i++)
{
int asciicode = (int)(array[i]);
asciicode = asciicode + 1;
byteArray[i]= asciicode ;
}
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;
}
追问在语句第十行“byteArray[i]= asciicode ;”在VS中会报错。并且 我修改成byteArray[i] = Convert .ToByte (asciicode); 在TXT1中输入ABC 结果还是显示D
追答第十行改成下面的样子。
byteArray[i]= (byte)asciicode;
下面俩句一定要在for循环外
string strCharacter = asciiEncoding.GetString(byteArray);
txt2.Text = strCharacter;