SHA1CryptoServiceProvider 和 SHA256Managed return 值应该相同吗

Should SHA1CryptoServiceProvider and SHA256Managed return same value

我看到一些问题表明生成了相同的散列,但代码如下:

    var password = "TestPassword";

    using (var hash = new SHA1CryptoServiceProvider())
    {
        var hashBytes = hash.ComputeHash(Encoding.UTF8.GetBytes(password));
        Console.WriteLine( Convert.ToBase64String(hashBytes) );
    }
    using (var managed = new SHA256Managed())
    {
        var hashBytes = managed.ComputeHash(Encoding.UTF8.GetBytes(password));
        Console.WriteLine(Convert.ToBase64String(hashBytes));
    }

输出为:

YlBiWyJt9ihwriOvjT+sB2DXFYg=
e8+diSmPG/rhb6Au1rYZCP0vqN5F3Y4hU6PEcwB2Uyg=

我没有正确使用加密库吗?

SHA1 和 SHA256 是两种不同的哈希函数。 (来源:https://en.wikipedia.org/wiki/Secure_Hash_Algorithms