コード例 #1
0
 public string this[string key, Encoding encoding = null]
 {
     get
     {
         encoding = encoding ?? Encoding.UTF8;
         var rsa = new RSACryptoServiceProvider();
         rsa.FromXmlString(_files.LoadPrivateKey());
         var vault = Vault;
         if (!vault.HasKey(key))
         {
             return(null);
         }
         return(encoding.GetString(rsa.Decrypt(vault[key])));
     }
 }
コード例 #2
0
 private void UpdateVault(string publicKey, string privateKey, RSACryptoServiceProvider rsa)
 {
     if (_files.VaultExists && _files.PrivateKeyExists)
     {
         var    vault         = _files.Load();
         string oldPrivateKey = _files.LoadPrivateKey();
         var    oldRsa        = new RSACryptoServiceProvider();
         oldRsa.FromXmlString(oldPrivateKey);
         CreateVault(publicKey, privateKey, Crypter.ReencryptVault(vault, oldRsa, rsa));
     }
     else
     {
         _files.DeletePublicKeyFile();
         _files.DeletePrivateKeyFile();
         _files.DeleteQuickVault();
         CreateVault(publicKey, privateKey);
     }
 }