IronPigeon.CryptoProviderExtensions.IsHashMatchWithTolerantHashAlgorithm C# (CSharp) Метод

IsHashMatchWithTolerantHashAlgorithm() статический приватный Метод

Computes the hash of the specified buffer and checks for a match to an expected hash.
static private IsHashMatchWithTolerantHashAlgorithm ( this cryptoProvider, byte data, byte expectedHash, HashAlgorithm hashAlgorithm ) : bool
cryptoProvider this The crypto provider.
data byte The data to hash.
expectedHash byte The expected hash.
hashAlgorithm HashAlgorithm The hash algorithm.
Результат bool
        internal static bool IsHashMatchWithTolerantHashAlgorithm(this CryptoSettings cryptoProvider, byte[] data, byte[] expectedHash, HashAlgorithm? hashAlgorithm)
        {
            Requires.NotNull(cryptoProvider, "cryptoProvider");
            Requires.NotNull(data, "data");
            Requires.NotNull(expectedHash, "expectedHash");

            if (!hashAlgorithm.HasValue)
            {
                hashAlgorithm = Utilities.GuessHashAlgorithmFromLength(expectedHash.Length);
            }

            var hasher = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(hashAlgorithm.Value);
            byte[] actualHash = hasher.HashData(data);
            return Utilities.AreEquivalent(expectedHash, actualHash);
        }