长话短说,我正在使用DES,并使用RSA进行密钥交换加密密码,密码不超过16个字符。问题在于,当我加密密钥时,加密后的大小变得太大,无法解密。以下是我的RSA加密和解密代码:
加密:--我一直尝试将localpwd设置为“asd”。
然后我在文本框中打印加密的密钥并尝试解密。
加密:--我一直尝试将localpwd设置为“asd”。
byte[] plaintext = utf8.GetBytes(localpwd);
byte[] ciphertext = rsaservice.Encrypt(plaintext, false);
string cipherresult = Convert.ToBase64String(ciphertext);
然后我在文本框中打印加密的密钥并尝试解密。
byte[] ciphertext = utf8.GetBytes(filetest.Text);
byte[] plain = rsaservice.Decrypt(ciphertext, true);
string plaintext = utf8.GetString(plain);
我收到了“要解密的数据超过了256字节的最大模数”错误提示。 我尝试增加密钥大小以便能够加密和解密更大的密钥,但增加密钥只会增加加密数据的大小,导致同样的错误。 请帮忙!
ToBase64String()
的反转。 - H H