VB.NET 相当于 PHP 哈希函数

A VB.NET equivalent of a PHP hash function

我无法将此 PHP 代码转换为 VB。

$hashpw = hash('sha256', $salt.$password.$salt)

我有这个VB代码

Public Function HashPassword(ByVal Password As String, ByVal Salt As String) As String
    Dim pwd As String = Salt & Password & Salt
    Dim hasher As New Security.Cryptography.SHA256Managed()
    Dim pwdb As Byte() = System.Text.Encoding.UTF8.GetBytes(pwd)
    Dim pwdh As Byte() = hasher.ComputeHash(pwdb)
    Return Convert.ToBase64String(pwdh)
End Function

但我从数据库中检索到的密码似乎与上面VB代码的返回值不等同。密码已使用上面的 PHP 代码加密。

谁能帮我解决这个问题? 非常感谢。谢谢。

php哈希函数returns数据以十六进制编码而不是base64。

Return BitConverter.ToString(pwdh).Replace("-", "")