我正在尝试使用RSA算法加密文本,并在加密后将其转换为字符串格式。 现在,虽然存在字节格式的加密文本,但我无法将其转换为字符串,因为存在保护级别错误。 我对加密系统很新,我不知道是否需要以某种方式处理数据才能进行复制/转换。 你能否澄清一下这件事?
这是一段代码:
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
UnicodeEncoding encode = new UnicodeEncoding();
RSAParameters PublicKey;
RSAParameters PrivateKey;
byte[] encBytes;
string encString;
// ********************* ENCRYPT THE TEXT WITH PUBLIC KEY *********************
private void buttonEncrypt_Click(object sender, RoutedEventArgs e)
{
rsa.ImportParameters(PublicKey);
encBytes = rsa.Encrypt(encode.GetBytes(textBoxIn.Text), false);
encString = encode.GetString(encBytes); <-- INACCESSIBLE DATA ERROR
rsa.Dispose();
}
由于