首页
社区
课程
招聘
这个不懂,有高人能吧它注解一下吗?谁删了我昨晚发的帖子???
发表于: 2004-5-9 10:34 5488

这个不懂,有高人能吧它注解一下吗?谁删了我昨晚发的帖子???

2004-5-9 10:34
5488
Option Explicit

Private Const szKeyNumber As String = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
Private Const nKeyLen As Long = 34

Private Function Digits(s As String) As Boolean
    Dim b As Boolean, i As Long, c As String
    b = True
    For i = 1 To Len(s)
        c = Mid(s, i, 1)
        If InStr(szKeyNumber, c) = 0 Then
            b = False
            Exit For
        End If
    Next
    Digits = b
End Function

Private Function GetKeyValue(Key As String) As Long
    Dim n As Long, i As Long, p As Long
    Dim d As Long
    d = nKeyLen
    n = 0
    For i = 1 To Len(Key)
        p = InStr(szKeyNumber, Mid$(Key, i, 1)) - 1
        n = n * d + p
    Next i
    GetKeyValue = n
End Function

Private Function MirrorLong(ByVal n As Long) As Long
    Dim p As Long, i As Long
    p = 0
    For i = 1 To 30
        p = p * 2 + (n And 1)
        n = n \ 2
    Next i
    MirrorLong = p
End Function

Public Function CheckKey(Key As String, Prefix As String, id As Long) As Long
    Dim s As String, s1 As String, s2 As String, s3 As String
    Dim b As Boolean, v1 As Long, v2 As Long
    Dim n As Long, nn As Double
    b = False
    s = UCase$(Trim$(Key))
    n = Len(Prefix)
    If Len(s) = 15 + n And Left$(s, n + 1) = Prefix & "-" And Mid$(s, 6 + n, 1) = "-" And Mid$(s, 11 + n, 1) = "-" Then
        s1 = Mid$(s, 2 + n, 4)
        s2 = Mid(s, 7 + n, 4)
        s3 = Mid(s, 12 + n)
        If Digits(s1) And Digits(s2) And Digits(s3) Then
            v1 = MirrorLong(GetKeyValue(s1 & Left$(s2, 2)))
            v2 = MirrorLong(GetKeyValue(s3 & Mid$(s2, 3)))
            n = nKeyLen * nKeyLen * nKeyLen
            n = n * n
            v1 = v1 And &H1FFFFFFF
            v2 = ((Not v2) And &H1FFFFFFF) Mod n
            b = (v1 = v2)
            v2 = v1 \ &H100000
            If b And v2 <> id Then b = False Else v1 = v1 And &HFFFFF
        End If
    End If
    CheckKey = IIf(b, v1, -1)
End Function

[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

收藏
免费 6
支持
分享
最新回复 (2)
雪    币: 222
活跃值: (100)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
CheckKeyVal = (CheckKey(Key, "SDSGN", 1) > -1)
2004-5-9 13:30
0
雪    币: 272
活跃值: (340)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
3
应该是vb的吧
Private Const szKeyNumber As String = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
Private Const nKeyLen As Long = 34

Private Function Digits(s As String) As Boolean
Dim b As Boolean, i As Long, c As String
b = True
For i = 1 To Len(s)
c = Mid(s, i, 1)
If InStr(szKeyNumber, c) = 0 Then
b = False
Exit For
End If
Next
Digits = b
End Function

Private Function GetKeyValue(Key As String) As Long
Dim n As Long, i As Long, p As Long
Dim d As Long
d = nKeyLen
n = 0
For i = 1 To Len(Key)
p = InStr(szKeyNumber, Mid$(Key, i, 1)) - 1
n = n * d + p
Next i
GetKeyValue = n
End Function

Private Function MirrorLong(ByVal n As Long) As Long
Dim p As Long, i As Long
p = 0
For i = 1 To 30
p = p * 2 + (n And 1)
n = n \ 2
Next i
MirrorLong = p
End Function

Public Function CheckKey(Key As String, Prefix As String, id As Long) As Long
Dim s As String, s1 As String, s2 As String, s3 As String
Dim b As Boolean, v1 As Long, v2 As Long
Dim n As Long, nn As Double
b = False
s = UCase$(Trim$(Key))
n = Len(Prefix)
If Len(s) = 15 + n And Left$(s, n + 1) = Prefix & "-" And Mid$(s, 6 + n, 1) = "-" And Mid$(s, 11 + n, 1) = "-" Then
s1 = Mid$(s, 2 + n, 4)
s2 = Mid(s, 7 + n, 4)
s3 = Mid(s, 12 + n)
If Digits(s1) And Digits(s2) And Digits(s3) Then
v1 = MirrorLong(GetKeyValue(s1 & Left$(s2, 2)))
v2 = MirrorLong(GetKeyValue(s3 & Mid$(s2, 3)))
n = nKeyLen * nKeyLen * nKeyLen
n = n * n
v1 = v1 And &H1FFFFFFF
v2 = ((Not v2) And &H1FFFFFFF) Mod n
b = (v1 = v2)
v2 = v1 \ &H100000
If b And v2 <> id Then b = False Else v1 = v1 And &HFFFFF
End If
End If
CheckKey = IIf(b, v1, -1)
End Function
2004-5-9 14:29
0
游客
登录 | 注册 方可回帖
返回
//