【发布时间】:2012-05-08 21:31:34
【问题描述】:
长话短说,我正在使用 DES 并使用 RSA 加密密码以进行密钥交换,密码不超过 16 个字符 问题是当我加密密钥时,加密的大小变得太大,我无法解密 这是我的 rsa 加密和解密代码:
加密:--我一直在尝试将 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()的反面 -
我正在使用 utf8 编码将其转换为字节并再次转换为字符串
标签: c# security encryption rsa encryption-asymmetric