函数使用vb.net在PHP中复制md5函数

函数使用vb.net在PHP中复制md5函数,php,vb.net,Php,Vb.net,我试图用vb.net复制PHP md5函数的功能,我的客户端和服务器脚本需要对传递的值应用相同的哈希函数。这就是我想到的,但它与PHPMD5不匹配 Public Function hashPassword(ByVal input As String) As String Dim salt As String = "asdf" Dim x As New System.Security.Cryptography.MD5CryptoServiceProvider()

我试图用vb.net复制PHP md5函数的功能,我的客户端和服务器脚本需要对传递的值应用相同的哈希函数。这就是我想到的,但它与PHPMD5不匹配

  Public Function hashPassword(ByVal input As String) As String
        Dim salt As String = "asdf"
        Dim x As New System.Security.Cryptography.MD5CryptoServiceProvider()
        Dim bs As Byte() = System.Text.Encoding.UTF8.GetBytes(input + salt)
        bs = x.ComputeHash(bs)
        Dim s As New System.Text.StringBuilder()
        For Each b As Byte In bs
            s.Append(b.ToString("x2"))
        Next
        Dim password As String = s.ToString()
        Return password
    End Function
你看过这个了吗:另外,你在PHP中使用的salt和在VB中使用的salt是一样的吗?正如Jonathan所写的,你可以尝试以下实现: