Option Explicit
dim param1 as string
dim param2 as stringFunction Check(StringInput as string) as Boolean
if ExtractString(stringInput,param1,param2) then
if Decipher(param1,param2,"LightWiter") then
check=true
else
check=false
end if
end function
Private Function Decipher(ByVal name As String, ByVal SerNo As String, ByVal OK_text) As Boolean
Const MIN_ASC = 32  ' Space.
Const MAX_ASC = 126 ' ~.
Const NUM_ASC = MAX_ASC - MIN_ASC + 1Dim to_text As String
Dim offset As Long
Dim str_len As Integer
Dim i As Integer
Dim ch As Integer    ' 初始化随机数生成
    offset = NumericPassword(name)
    Rnd -1
    Randomize offset    '解码
    str_len = Len(SerNo)
    For i = 1 To str_len
        ch = Asc(Mid$(SerNo, i, 1))
        If ch >= MIN_ASC And ch <= MAX_ASC Then
            ch = ch - MIN_ASC
            offset = Int((NUM_ASC + 1) * Rnd)
            ch = ((ch - offset) Mod NUM_ASC)
            If ch < 0 Then ch = ch + NUM_ASC
            ch = ch + MIN_ASC
            to_text = to_text & Chr$(ch)
        End If
    Next i
If to_text = OK_text Then
Decipher = True
Else
Decipher = False
End If
End Function
' 转换密码偏移值
Private Function NumericPassword(ByVal name As String) As Long
Dim value As Long
Dim ch As Long
Dim shift1 As Long
Dim shift2 As Long
Dim i As Integer
Dim str_len As Integer    str_len = Len(name)
    For i = 1 To str_len
        ' 添加下一个字符
        ch = Asc(Mid$(name, i, 1))
        value = value Xor (ch * 2 ^ shift1)
        value = value Xor (ch * 2 ^ shift2)        ' 改变偏移值
        shift1 = (shift1 + 7) Mod 19
        shift2 = (shift2 + 13) Mod 23
    Next i
    NumericPassword = value
End FunctionPrivate Function ExtractString(stringInput as string ,param1 As String, Param2 As String) As Boolean
If stringInput = "" Then
ExtractString = False
Exit Function
Else
Dim strCMD As String
Dim numSERTHpostion As Long
Dim cmdtext As String
cmdtext = stringInput
numSERTHpostion = InStr(cmdtext, Chr(32))
Param1 = Left(cmdtext, numSERTHpostion - 1)
Param2 = Mid(cmdtext, numSERTHpostion + 1)
ExtractString = True
End If
End Function
我是要把上面一段代码编成DLL然后给安装程序调用
我搞了好久都没有搞定,只好请教大侠了,还请多多关照.