/// <summary> /// Verifies the hash. /// </summary> /// <param name="data">The data.</param> /// <param name="hash">The hash.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// data /// or /// hash /// </exception> public bool VerifyHash(byte[] data, byte[] hash) { if (data == null || data.Length == 0) { throw new ArgumentNullException(nameof(data)); } if (hash == null || hash.Length == 0) { throw new ArgumentNullException(nameof(hash)); } using (var managedHashProvider = new SHA256Managed()) { var salt = managedHashProvider.ExtractRandomSalt(hash); var computedHash = ComputeHash(data, salt); return(string.Equals(Convert.ToBase64String(hash), Convert.ToBase64String(computedHash))); } }