[英]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 hash函数返回以十六进制而不是base64编码的数据。
Return BitConverter.ToString(pwdh).Replace("-", "")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.