Beispiel #1
0
        /// <summary>
        /// Compares plain text input with a computed hash using the configured <c>HashAlgorithm</c>.
        /// <seealso cref="IHashProvider.CompareHash"/>
        /// </summary>
        /// <param name="plaintext"><seealso cref="IHashProvider.CompareHash"/></param>
        /// <param name="hashedtext"><seealso cref="IHashProvider.CompareHash"/></param>
        /// <returns><seealso cref="IHashProvider.CompareHash"/></returns>
        public bool CompareHash(byte[] plaintext, byte[] hashedtext)
        {
            ArgumentValidation.CheckForNullReference(plaintext, "plainText");
            ArgumentValidation.CheckForNullReference(hashedtext, "hashedText");
            ArgumentValidation.CheckForZeroBytes(hashedtext, "hashedText");

            bool result = false;

            byte[] hashedPlainText = null;
            byte[] salt            = null;
            try
            {
                salt            = ExtractSalt(hashedtext);
                hashedPlainText = CreateHashWithSalt(plaintext, salt);
            }
            finally
            {
                CryptographyUtility.ZeroOutBytes(salt);
            }
            result = CryptographyUtility.CompareBytes(hashedPlainText, hashedtext);
            SecurityCryptoHashCheckEvent.Fire(string.Empty);
            if (!result)
            {
                SecurityCryptoHashCheckFailureEvent.Fire(string.Empty);
            }
            return(result);
        }
Beispiel #2
0
 private void FireSecurityCryptoHashCheckEvent()
 {
     SecurityCryptoHashCheckEvent.Fire(testMessage);
 }
 private void FireSecurityCryptoHashCheckEvent()
 {
     SecurityCryptoHashCheckEvent.Fire("test");
 }