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

时间:2012-02-06 03:59:54

标签: php vb.net

我正在尝试使用vb.net复制PHP md5函数的功能,我的客户端和服务器脚本需要将相同的哈希函数应用于传递的值。这就是我想出来的,但它不匹配php md5

  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

0 个答案:

没有答案