Reputation: 396
Lets say, Person1 has two files: person1.public.key and person1.private.key. This person uses his person1.private.key to encrypt a message and send it to me.
I only have the file person1.public.key, and I want to decrypt the message sent to me.
How to:
I did search online, but all examples I saw was the code generating the keys on runtime. I want to use the keys in the files.
Upvotes: 0
Views: 1357
Reputation: 54605
Did you try using RSA.ImportFromPem(...)?
It supports the following PEM labels:
var keyString = loadFileIntoReadyOnlySpan();
var rsaKey = RSA.Create();
rsaKey.ImportFromPem(keyString);
I assume you know/can figure out how to load a file
Upvotes: 1