Вот код, который работает нормально при чтении файла из txt, но когда я читаю его из строки, я получаю здесь ошибку
public string encrypt(string plainText,string PrivateKey)
{
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
string filepath = path + "\\rsakeys\\pem_public.pem";
string localPath = new Uri(filepath).LocalPath;
PemReader pr = new PemReader(
(StreamReader)File.OpenText(localPath)
);
var reader = new StringReader(PrivateKey);
var pre = new PemReader(reader);
var o = pr.ReadObject();
var os = pre.ReadObject();
RsaKeyParameters keys = (RsaKeyParameters)os; >>> Here i am getting the error where os is the object readed from the string
Подробнее здесь: https://stackoverflow.com/questions/645 ... herkeypair
Невозможно привести объект типа «Org.BouncyCastle.Crypto.AsymmetricCipherKeyPair» к типу «Org.BouncyCastle.Crypto.Parame ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение