What is the correct way to save a cryptographic key?

I have:

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

And any of them:

byte[] Csp = rsa.ExportCspBlob(true);
RSAParameters parameters = rsa.ExportParameters(true);

What is the correct way to save them and what file extension should I use? Note. I do not mean how to encrypt them. How to store them.

+3
source share
1 answer

I would just use it RSACryptoServiceProvider.PersistKeyInCsp = true. Make sue that CspParameters.KeyContainerNamecontains a unique identifiable name for the key.

To transfer the public key, use export to Xml.

+2
source

All Articles