C#编写三种DES加解密桌面应用程序时出现“要解密的数据长度无效”的问题
privatevoidbutton2_Click(objectsender,EventArgse){byte[]x_plaintext1=Encoding.Default...
private void button2_Click(object sender, EventArgs e) { byte[] x_plaintext1 = Encoding.Default.GetBytes(textBox3.Text); MemoryStream x_memory_stream = new MemoryStream(); SymmetricAlgorithm x_alg = SymmetricAlgorithm.Create("TripleDES"); ICryptoTransform x_decryptor = x_alg.CreateDecryptor(); CryptoStream x_cryptostream = new CryptoStream(x_memory_stream, x_decryptor, CryptoStreamMode.Write); x_cryptostream.Write(x_plaintext1, 0, x_plaintext1.Length); x_cryptostream.Close();//出错在这里。要解密的数据长度无效 byte[] x_ciphertext = x_memory_stream.ToArray(); string a1 = Encoding.Default.GetString(x_ciphertext); label9.Text = a1; }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询