【发布时间】:2011-08-16 07:48:25
【问题描述】:
大家好 我正在构建客户端/服务器会议系统
我遇到了一个问题“无法将类型 'string' 隐式转换为 'System.Security.Cryptography.RSAParameters'”
我会快速解释这个过程
- 客户端连接到服务器
- 服务器发回他的公钥
- 客户端将通过服务器公钥加密用户名+他的公钥
我收到了服务器回复(公钥),但是当我尝试使用 RSA 加密时出现上述错误
这是我的代码:
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
// mess is Server response as string
RSAParameters publickey = mess;
rsa.ImportParameters(publickey);
byte[] encryptedData = rsa.Encrypt(StringToByte(uname.Text + "|||" + PUBKEY), true);
【问题讨论】:
标签: c# encryption cryptography rsa