public bool Delete() { try { // if a rsaprovider exists, make non persistent, clear it and nullify --> the key is deleted if (RsaProvider.IsAssigned()) { // Delete the key entry in the container. RsaProvider.PersistKeyInCsp = false; // Call Clear to release resources and delete the key from the container. RsaProvider.Clear(); RsaProvider = null; return(true); } return(false); } catch (CryptographicException e) { Debug.WriteLine("Encryption: UtilHelper.DeleteKeyFromContainer(...) unable to delete key - " + e.Message); return(false); } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (RsaProvider.IsAssigned()) { RsaProvider.Clear(); // resources vrijgeven. RsaProvider = null; } } _disposed = true; }