本帖最后由 sdc7 于 2012-7-19 08:27 编辑
Function EncodePassword(ByVal pass As String, ByVal challange As String) As String
Dim hash_byte(challange.Length / 2 - 1) As Byte
For i = 0 To challange.Length - 2 Step 2
hash_byte(i / 2) = Byte.Parse(challange.Substring(i, 2), Globalization.NumberStyles.HexNumber)
Next
Dim response(pass.Length + hash_byte.Length) As Byte
response(0) = 0
Text.Encoding.ASCII.GetBytes(pass.ToCharArray()).CopyTo(response, 1)
hash_byte.CopyTo(response, 1 + pass.Length)
Dim md5 = New System.Security.Cryptography.MD5CryptoServiceProvider()
Dim hash = md5.ComputeHash(response)
Dim hashStr As New Text.StringBuilder()
For Each h In hash
hashStr.Append(h.ToString("x2"))
Next
Return hashStr.ToString()
End Function
别的方法实现~ |