我有一个软件注册的小程序,输入用户名,硬盘序列号,注册码(根据用户名和硬盘序列号生成的)就会注册成功了,代码:Private Sub Command1_Click()
userid = Text1.text '用户名
disk = Text3.text '硬盘序列号
sn = Text2.text '注册码
Temp = password.crypt("D", disk, sn)
If Temp <> userid Then
MsgBox "注册不成功,请重新注册"
Else
MsgBox "注册成功!谢谢使用本软件"
End If
End Sub类password:
Function crypt(Action As String, Key As String, Src As String) As String
Dim Count As Integer, KeyPos As Integer, KeyLen As Integer, SrcAsc As Integer, dest As String, offset As Integer, TmpSrcAsc, SrcPos
KeyLen = Len(Key)
If Action = "E" Then
Randomize
offset = (Rnd * 10000 Mod 255) + 1
dest = Hex$(offset)
If Len(dest) = 1 Then
dest = "0" + dest
End If
For SrcPos = 1 To Len(Src)
SrcAsc = (Asc(Mid$(Src, SrcPos, 1)) + offset) Mod 255
If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1
SrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1))
dest = dest + Format$(Hex$(SrcAsc), "@@")
offset = SrcAsc
Next
ElseIf Action = "D" Then
offset = Val("&H" + Left$(Src, 2))
For SrcPos = 3 To Len(Src) Step 2
SrcAsc = Val("&H" + Trim(Mid$(Src, SrcPos, 2)))
If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1
TmpSrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1))
If TmpSrcAsc <= offset Then
TmpSrcAsc = 255 + TmpSrcAsc - offset
Else
TmpSrcAsc = TmpSrcAsc - offset
End If
dest = dest + Chr(TmpSrcAsc)
offset = SrcAsc
Next
End If
crypt = dest
End Function现在有问题:
1,硬盘序列号为:1069347913,但是输入106934791,10693479,1069347,106934,10693也都是有效的,大家可以注意观察一下规律。
2,如果用户名,硬盘序列号,注册码都为空值也是有效的。
请问这是怎么回事?
该如何改动?
userid = Text1.text '用户名
disk = Text3.text '硬盘序列号
sn = Text2.text '注册码
Temp = password.crypt("D", disk, sn)
If Temp <> userid Then
MsgBox "注册不成功,请重新注册"
Else
MsgBox "注册成功!谢谢使用本软件"
End If
End Sub类password:
Function crypt(Action As String, Key As String, Src As String) As String
Dim Count As Integer, KeyPos As Integer, KeyLen As Integer, SrcAsc As Integer, dest As String, offset As Integer, TmpSrcAsc, SrcPos
KeyLen = Len(Key)
If Action = "E" Then
Randomize
offset = (Rnd * 10000 Mod 255) + 1
dest = Hex$(offset)
If Len(dest) = 1 Then
dest = "0" + dest
End If
For SrcPos = 1 To Len(Src)
SrcAsc = (Asc(Mid$(Src, SrcPos, 1)) + offset) Mod 255
If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1
SrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1))
dest = dest + Format$(Hex$(SrcAsc), "@@")
offset = SrcAsc
Next
ElseIf Action = "D" Then
offset = Val("&H" + Left$(Src, 2))
For SrcPos = 3 To Len(Src) Step 2
SrcAsc = Val("&H" + Trim(Mid$(Src, SrcPos, 2)))
If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1
TmpSrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1))
If TmpSrcAsc <= offset Then
TmpSrcAsc = 255 + TmpSrcAsc - offset
Else
TmpSrcAsc = TmpSrcAsc - offset
End If
dest = dest + Chr(TmpSrcAsc)
offset = SrcAsc
Next
End If
crypt = dest
End Function现在有问题:
1,硬盘序列号为:1069347913,但是输入106934791,10693479,1069347,106934,10693也都是有效的,大家可以注意观察一下规律。
2,如果用户名,硬盘序列号,注册码都为空值也是有效的。
请问这是怎么回事?
该如何改动?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货