I am using System.Security.Cryptography.Cng
(4.7.0).
I have exported a public key from a CngKey
object using
byte[] publicKey = cngKey.Export(CngKeyBlobFormat.GenericPublicBlob);
How can I use this at a later time to create an RSACng
object for public-key encryption?
A CngKey
can be recreated from the blob like this:
using CngKey key = CngKey.Import(blob, CngKeyBlobFormat.GenericPublicBlob);
And then we can create an RSACng
for e.g. encrypting data:
using RSACng rsaCng = new RSACng(key);