VB:
点击下载:附件!
Public Function GenerateKey(ByVal Name As String) As String
Dim lPart1 As Long
Dim lPart2 As Long
Dim ch As Long
Dim i As Long
Dim n As Long
Name = Trim$(Name)
Name = Mid$(Name, 1, 40)
If Len(Name) = 0 Then
Exit Function
End If
For i = 1 To Len(Name)
ch = Asc(Mid$(Name, i, 1)) * &H100
For n = 1 To 8
If (((ch Xor lPart1) Mod &H10000) And &H8000&) = 0 Then
lPart1 = lPart1 And &HFFFFFFF
lPart1 = lPart1 * 2
Else
lPart1 = lPart1 And &HFFFFFFF
lPart1 = lPart1 * 2
lPart1 = lPart1 Xor &H1021&
End If
ch = ch * 2
Next n
Next i
lPart1 = lPart1 + &H63&
lPart1 = lPart1 Mod &H10000
For i = 1 To Len(Name)
lPart2 = lPart2 + (Asc(Mid$(Name, i, 1)) * (i - 1))
Next i
GenerateKey = String$(4 - Len(CStr(Hex(lPart1))), "0") _
& CStr(Hex(lPart1)) _
& String$(4 - Len(CStr(Hex(lPart2))), "0") _
& CStr(Hex(lPart2))
End Function
Private Sub Text1_Change()
Text2.Text = GenerateKey(Text1)
End Sub