Ade*_*med 3 c# security encryption rsa encryption-asymmetric
长话短说,我正在使用DES而我正在使用RSA加密密码进行密钥交换,密码不超过16个字符问题是当我加密密钥时,加密的大小对我来说太大了解密这里是我的rsa加密和解密代码:
加密: - 我一直在尝试将localpwd作为"asd"
byte[] plaintext = utf8.GetBytes(localpwd);
byte[] ciphertext = rsaservice.Encrypt(plaintext, false);
string cipherresult = Convert.ToBase64String(ciphertext);
Run Code Online (Sandbox Code Playgroud)
然后我打印文本框上的加密密钥并尝试解密
byte[] ciphertext = utf8.GetBytes(filetest.Text);
byte[] plain = rsaservice.Decrypt(ciphertext, true);
string plaintext = utf8.GetString(plain);
Run Code Online (Sandbox Code Playgroud)
我得到"要解密的数据超过这个256字节模数的最大值".我尝试增加密钥大小,以便能够加密和解密更大的密钥大小,但增加密钥只会增加加密数据的大小导致相同的错误,请帮助!
//byte[] ciphertext = utf8.GetBytes(filetest.Text);
byte[] ciphertext = Convert.FromBase64String(filetest.Text);
Run Code Online (Sandbox Code Playgroud)