我需要此函数来创建质询密码以查询第三方SOAP提供程序。
我在c#中找到了这个解决方案:
Simulating MySql OLD_PASSWORD in .NET or MS SQL?
但将其翻译为vb.net似乎远远高于我的技能水平。
我的其他选择是:
所有这些看起来都很糟糕。如果有人能提供任何帮助,我们将不胜感激。
答案 0 :(得分:1)
Public Function mysql_old_password(sPassword As String) As String
Dim result As UInt32() = New UInt32(1) {}
Dim nr As UInt32 = 1345345333, add As UInt32 = 7, nr2 As UInt32 = &H12345671
Dim tmp As UInt32
Dim password As Char() = sPassword.ToCharArray()
Dim i As Int32
For i = 0 To sPassword.Length - 1
If password(i) = " "c OrElse password(i) = ControlChars.Tab Then
Continue For
End If
tmp = AscW(password(i))
nr = nr Xor (((nr And 63) + add) * tmp) + (nr << 8)
On Error GoTo 0
nr2 += (nr2 << 8) Xor nr
add += tmp
Next
Dim one As UInt32 = 1
result(0) = nr And ((one << 31) - 1)
Dim val As UInt32 = ((one << 31) - 1)
result(1) = nr2 And val
Dim hash As String = [String].Format("{0:X}{1:X}", result(0), result(1))
Return hash.ToLower()
End Function