Esempio n. 1
0
        private ProtectedKey ProtectKey(byte[] decryptedKey, DataProtectionScope protectionScope)
        {
            ProtectedKey result = ProtectedKey.CreateFromPlaintextKey(decryptedKey, protectionScope);

            Utility.ZeroOutBytes(decryptedKey);
            return(result);
        }
 public static void WriteKey(byte[] key, string keyFile, DataProtectionScope dpapiProtectionScope)
 {
     //Write the key to the DPAPI protected key file
     using (FileStream fs = new FileStream(keyFile, FileMode.Create))
     {
         ProtectedKey protectedKey = ProtectedKey.CreateFromPlaintextKey(
             key, dpapiProtectionScope);
         KeyManager.Write(fs, protectedKey);
         fs.Flush();
         fs.Close();
     }
 }