private ProtectedKey GenerateKey(KeyedHashAlgorithm algorithm, DataProtectionScope dataProtectionScope)
 {
     using (algorithm)
     {
         return(ProtectedKey.CreateFromPlaintextKey(algorithm.Key, dataProtectionScope));
     }
 }
Пример #2
0
        private ProtectedKey ProtectKey(byte[] decryptedKey, DataProtectionScope protectionScope)
        {
            ProtectedKey protectedKey = ProtectedKey.CreateFromPlaintextKey(decryptedKey, protectionScope);

            CryptographyUtility.ZeroOutBytes(decryptedKey);

            return(protectedKey);
        }
 private ProtectedKey GenerateKey(SymmetricAlgorithm algorithm, DataProtectionScope dataProtectionScope)
 {
     byte[] generatedKey = GenerateUnprotectedKey(algorithm);
     try
     {
         return(ProtectedKey.CreateFromPlaintextKey(generatedKey, dataProtectionScope));
     }
     finally
     {
         if (generatedKey != null)
         {
             CryptographyUtility.ZeroOutBytes(generatedKey);
         }
     }
 }