public void LoadKeys(string masterPassword) { string pathToKeyFile = GetPrivateKeyPath(UserId); var rsaKeysXml = FileCryptor.LoadAndDecryptRsaKeys(pathToKeyFile, masterPassword); rsa = new RSACryptoServiceProvider(); rsa.FromXmlString(rsaKeysXml); rsa.PersistKeyInCsp = true; }
public void SaveKeys(string masterPassword, bool force = false) { string pathToKeyFile = GetPrivateKeyPath(UserId); if (!File.Exists(pathToKeyFile) || force) { var rsaKeysXml = rsa.ToXmlString(true); FileCryptor.EncryptAndSaveRsaKeys(rsaKeysXml, pathToKeyFile, masterPassword); } else { throw new ArgumentException("Keys for this user already exist!"); } }