To securely store keys, they should be stored in the key container, rather than in plain text.
If you do not know about key containers, you can refer to msdn to learn about computer-level and user-level RSA key containers.
CspparametersThe namespace of is:
System. Security. Cryptography
Create and read a key container
Cspparameters CP = new cspparameters ();
CP. keycontainername = containername;
Rsacryptoserviceprovider RSA = new rsacryptoserviceprovider (CP );
Use the preceding steps to create and read a secret containerCode: If the key container does not exist, it will be automatically created and the key generated by RSA will be saved to it; if it already exists, the key will be read to RSA.
Delete key container
Cspparameters CP = new cspparameters ();
CP. keycontainername = containername;
Rsacryptoserviceprovider RSA = new rsacryptoserviceprovider (CP );
RSA. persistkeyincsp = false;
RSA. Clear ();
There are two more sentences than creating and reading.
Security:ProgramCan program B read the creation of a and key container?
Yes. If you want to restrict program B from reading, see the above-mentioned understanding of Computer-level and user-level RSA key containers.