加密
1 Private Sub Form_Load()
2 MsgBox Encode("12345671") = "4E5051525354554E"
3 End Sub
4 Function Encode(sPass)
5 Dim i, tStr, sTmp
6 For i = 1 To Len(sPass)
7 sTmp = Asc(Mid(sPass, i, 1))
8 tStr = tStr & Abs(sTmp)
9 Next
10 sPass = tStr
11 tStr = ""
12 Do While Len(sPass) > 16
13 sPass = JoinCutStr(sPass)
14 Loop
15 For i = 1 To Len(sPass)
16 sTmp = CInt(Mid(sPass, i, 1))
17 sTmp = Y(sTmp > 6, Chr(sTmp + 60), sTmp)
18 tStr = tStr & sTmp
19 Next
20 Encode = tStr
21 End Function
22 Function JoinCutStr(s)
23 Dim i, tStr
24 For i = 1 To Len(s)
25 If Len(s) - i = 0 Then Exit For
26 tStr = tStr & Chr(CInt((Asc(Mid(s, i, 1)) + Asc(Mid(s, i + 1, 1))) / 2))
27 i = i + 1
28 Next
29 JoinCutStr = tStr
30 End Function
31 Function Y(var, val1, val2)
32 If var = True Then Y = val1 Else Y = val2
33 End Function
2 MsgBox Encode("12345671") = "4E5051525354554E"
3 End Sub
4 Function Encode(sPass)
5 Dim i, tStr, sTmp
6 For i = 1 To Len(sPass)
7 sTmp = Asc(Mid(sPass, i, 1))
8 tStr = tStr & Abs(sTmp)
9 Next
10 sPass = tStr
11 tStr = ""
12 Do While Len(sPass) > 16
13 sPass = JoinCutStr(sPass)
14 Loop
15 For i = 1 To Len(sPass)
16 sTmp = CInt(Mid(sPass, i, 1))
17 sTmp = Y(sTmp > 6, Chr(sTmp + 60), sTmp)
18 tStr = tStr & sTmp
19 Next
20 Encode = tStr
21 End Function
22 Function JoinCutStr(s)
23 Dim i, tStr
24 For i = 1 To Len(s)
25 If Len(s) - i = 0 Then Exit For
26 tStr = tStr & Chr(CInt((Asc(Mid(s, i, 1)) + Asc(Mid(s, i + 1, 1))) / 2))
27 i = i + 1
28 Next
29 JoinCutStr = tStr
30 End Function
31 Function Y(var, val1, val2)
32 If var = True Then Y = val1 Else Y = val2
33 End Function