public void ExportPrivateKey(string filename) { if (Rsa.PublicOnly) { throw new Exception("no private key!"); } AesFileEncryptionPrivider.WriteFile(PrivateKey, filename); }
public KeyContainer(string filepath) { PrivateKey = AesFileEncryptionPrivider.ReadFile(filepath); Rsa = new RSACryptoServiceProvider(); Rsa.ImportCspBlob(PrivateKey); PrivateKey = Rsa.ExportCspBlob(true); PublicKey = Rsa.ExportCspBlob(false); PublicKeyS = Convert.ToBase64String(PublicKey); }