相当于PHP哈希函数的VB.NET

相当于PHP哈希函数的VB.NET,php,vb.net,hash,sha256,Php,Vb.net,Hash,Sha256,我在将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.

我在将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哈希函数返回以十六进制而非base64编码的数据

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