大家讨论一下附加码的技术思路和实现方法!
---------------------------------------------------------------
版权所有 转载请保留 谢谢合作
部分程序取自网络
作者:扬子
Email: [email protected]
QQ: 21112856
WebSite: www.tingfo.net
一共4个页面:form.asp; chk.asp; num.asp; count.asp
得到一个随即数字。加密!
解密后成成XBM图片
利用session 判断
form.asp
1
2'### To encrypt/decrypt include this code in your page
3'### strMyEncryptedString = EncryptString(strString)
4'### strMyDecryptedString = DeCryptString(strMyEncryptedString)
5'### You are free to use this code as long as credits remain in place
6'### also if you improve this code let me know.
7
8Private Function EncryptString(strString)
9'####################################################################
10'### Crypt Function (C) 2001 by Slavic Kozyuk [email protected] ###
11'### Arguments: strString <\--- String you wish to encrypt ###
12'### Output: Encrypted HEX string ###
13'####################################################################
14
15Dim CharHexSet, intStringLen, strTemp, strRAW, i, intKey, intOffSet
16Randomize Timer
17
18intKey = Round((RND * 1000000) + 1000000) '##### Key Bitsize
19intOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize
20
21If IsNull(strString) = False Then
22strRAW = strString
23intStringLen = Len(strRAW)
24
25For i = 0 to intStringLen - 1
26strTemp = Left(strRAW, 1)
27strRAW = Right(strRAW, Len(strRAW) - 1)
28CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)& Hex(intKey)
29Next
30
31EncryptString = CharHexSet & " ¦" & Hex(intOffSet + intKey) & " ¦" & Hex(intOffSet)
32Else
33EncryptString = ""
34End If
35End Function
36
37
38
39\---------------------------------------------------------------
40
41
42
43
44
45Private Function DeCryptString(strCryptString)
46'####################################################################
47'### Crypt Function (C) 2001 by Slavic Kozyuk [email protected] ###
48'### Arguments: Encrypted HEX stringt ###
49'### Output: Decrypted ASCII string ###
50'####################################################################
51'### Note this function uses HexConv() and get_hxno() functions ###
52'### so make sure they are not removed ###
53'####################################################################
54
55Dim strRAW, arHexCharSet, i, intKey, intOffSet, strRawKey, strHexCrypData
56
57
58strRawKey = Right(strCryptString, Len(strCryptString) - InStr(strCryptString, " ¦"))
59intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey," ¦"))
60intKey = HexConv(Left(strRawKey, InStr(strRawKey, " ¦") - 1)) - HexConv(intOffSet)
61strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1))
62
63
64arHexCharSet = Split(strHexCrypData, Hex(intKey))
65
66For i=0 to UBound(arHexCharSet)
67strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey)
68Next
69
70DeCryptString = strRAW
71End Function
72
73
74
75Private Function HexConv(hexVar)
76Dim hxx, hxx_var, multiply
77IF hexVar <> "" THEN
78hexVar = UCASE(hexVar)
79hexVar = StrReverse(hexVar)
80DIM hx()
81REDIM hx(LEN(hexVar))
82hxx = 0
83hxx_var = 0
84FOR hxx = 1 TO LEN(hexVar)
85IF multiply = "" THEN multiply = 1
86hx(hxx) = mid(hexVar,hxx,1)
87hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var
88multiply = (multiply * 16)
89NEXT
90hexVar = hxx_var
91HexConv = hexVar
92END IF
93End Function
94
95Private Function get_hxno(ghx)
96If ghx = "A" Then
97ghx = 10
98ElseIf ghx = "B" Then
99ghx = 11
100ElseIf ghx = "C" Then
101ghx = 12
102ElseIf ghx = "D" Then
103ghx = 13
104ElseIf ghx = "E" Then
105ghx = 14
106ElseIf ghx = "F" Then
107ghx = 15
108End If
109get_hxno = ghx
110End Function
111
112
---------------------------------------------------------------
1
2randomize
3num = int(7999*rnd+2000) '计数器的值
4num2 = EncryptString(num)
5session("pwdt")=num
1<form action="chk.asp" method="post">
2请输入验证码: <input name="pwds" type="text"/>
3<img src="count.asp?sksid=```
4=num2
5```"/> <input type="submit" value="提交"/>
6</form>
chk.asp
1
2if trim(request.form("pwds"))<>trim(session("pwdt")) then
输入错误: 应该为:=session("pwdt"),可你输入的是:```
=request.form("pwds")
else
1输入正确
end if
1
2count.asp
3<!--#include file="num.asp"-->
'### To encrypt/decrypt include this code in your page
'### strMyEncryptedString = EncryptString(strString)
'### strMyDecryptedString = DeCryptString(strMyEncryptedString)
'### You are free to use this code as long as credits remain in place
'### also if you improve this code let me know.
Private Function EncryptString(strString)
'####################################################################
'### Crypt Function (C) 2001 by Slavic Kozyuk [email protected] ###
'### Arguments: strString <--- String you wish to encrypt ###
'### Output: Encrypted HEX string ###
'####################################################################
Dim CharHexSet, intStringLen, strTemp, strRAW, i, intKey, intOffSet
Randomize Timer
intKey = Round((RND * 1000000) + 1000000) '##### Key Bitsize
intOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize
If IsNull(strString) = False Then
strRAW = strString
intStringLen = Len(strRAW)
For i = 0 to intStringLen - 1
strTemp = Left(strRAW, 1)
strRAW = Right(strRAW, Len(strRAW) - 1)
CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)& Hex(intKey)
Next
EncryptString = CharHexSet & " ¦" & Hex(intOffSet + intKey) & " ¦" & Hex(intOffSet)
Else
EncryptString = ""
End If
End Function
Private Function DeCryptString(strCryptString)
'####################################################################
'### Crypt Function (C) 2001 by Slavic Kozyuk [email protected] ###
'### Arguments: Encrypted HEX stringt ###
'### Output: Decrypted ASCII string ###
'####################################################################
'### Note this function uses HexConv() and get_hxno() functions ###
'### so make sure they are not removed ###
'####################################################################
Dim strRAW, arHexCharSet, i, intKey, intOffSet, strRawKey, strHexCrypData
strRawKey = Right(strCryptString, Len(strCryptString) - InStr(strCryptString, " ¦"))
intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey," ¦"))
intKey = HexConv(Left(strRawKey, InStr(strRawKey, " ¦") - 1)) - HexConv(intOffSet)
strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1))
arHexCharSet = Split(strHexCrypData, Hex(intKey))
For i=0 to UBound(arHexCharSet)
strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey)
Next
DeCryptString = strRAW
End Function
---------------------------------------------------------------
<%Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = -1
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "No-Cache"
1<%
2function makePassword(maxLen)
3Dim strNewPass
4Dim whatsNext, upper, lower, intCounter
5Randomize
6For intCounter = 1 To maxLen
7whatsNext = Int((1 - 0 + 1) * Rnd + 0)
8If whatsNext = 0 Then
9'character
10upper = 90
11lower = 65
12Else
13upper = 57
14lowe