|
<p><strong>一个很简单的验证码程序</strong></p><hr/><p>主程序共三个 </p><p>我的调用方式 <script language="javascript" src="/verify/num.asp"></script> <br/>验证方式 if trim(Loginnum)<>trim(session("Loginnum")) then <br/>Response.Write Error("验证码错误!") <br/>Response.End <br/>end if </p><p><br/>num.asp </p><p><% <br/>'### To encrypt/decrypt include this code in your page <br/>'### strMyEncryptedString = EncryptString(strString) <br/>'### strMyDecryptedString = DeCryptString(strMyEncryptedString) <br/>'### You are free to use this code as long as credits remain in place <br/>'### also if you improve this code let me know. </p><p> rivate Function EncryptString(strString) <br/>'#################################################################### <br/>'### Crypt Function ? 2001 by Slavic Kozyuk grindkore@yahoo.com ### <br/>'### Arguments: strString <--- String you wish to encrypt ### <br/>'### Output: Encrypted HEX string ### <br/>'#################################################################### </p><p>Dim CharHexSet, intStringLen, strTemp, strRAW, I, intKey, intOffSet <br/>Randomize Timer </p><p>intKey = Round((RND * 1000000) + 1000000) '##### Key Bitsize <br/>intOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize </p><p>If IsNull(strString) = False Then <br/>strRAW = strString <br/>intStringLen = Len(strRAW) </p><p>For i = 0 to intStringLen - 1 <br/>strTemp = Left(strRAW, 1) <br/>strRAW = Right(strRAW, Len(strRAW) - 1) <br/>CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)& Hex(intKey) <br/>Next </p><p>EncryptString = CharHexSet & "|" & Hex(intOffSet + intKey) & "|" & Hex(intOffSet) <br/>Else <br/>EncryptString = "" <br/>End If <br/>End Function </p><p></p><p><br/> rivate Function DeCryptString(strCryptString) <br/>'#################################################################### <br/>'### Crypt Function ? 2001 by Slavic Kozyuk grindkore@yahoo.com ### <br/>'### Arguments: Encrypted HEX stringt ### <br/>'### Output: Decrypted ASCII string ### <br/>'#################################################################### <br/>'### Note this function uses HexConv() and get_hxno() functions ### <br/>'### so make sure they are not removed ### <br/>'#################################################################### </p><p>Dim strRAW, arHexCharSet, I, intKey, intOffSet, strRawKey, strHexCrypData </p><p><br/>strRawKey = Right(strCryptString, Len(strCryptString) - InStr(strCryptString, "|")) <br/>intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey,"|")) <br/>intKey = HexConv(Left(strRawKey, InStr(strRawKey, "|") - 1)) - HexConv(intOffSet) <br/>strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1)) </p><p><br/>arHexCharSet = Split(strHexCrypData, Hex(intKey)) </p><p>For i=0 to Ubound(arHexCharSet) <br/>strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey) <br/>Next </p><p>DeCryptString = strRAW <br/>End Function </p><p></p><p> rivate Function HexConv(hexVar) <br/>Dim hxx, hxx_var, multiply <br/>IF hexVar <> "" THEN <br/>hexVar = UCASE(hexVar) <br/>hexVar = StrReverse(hexVar) <br/>DIM hx() <br/>REDIM hx(LEN(hexVar)) <br/>hxx = 0 <br/>hxx_var = 0 <br/>FOR hxx = 1 TO LEN(hexVar) <br/>IF multiply = "" THEN multiply = 1 <br/>hx(hxx) = mid(hexVar,hxx,1) <br/>hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var <br/>multiply = (multiply * 16) <br/>NEXT <br/>hexVar = hxx_var <br/>HexConv = hexVar <br/>END IF <br/>End Function </p><p> rivate Function get_hxno(ghx) <br/>If ghx = "A" Then <br/>ghx = 10 <br/>ElseIf ghx = "B" Then <br/>ghx = 11 <br/>ElseIf ghx = "C" Then <br/>ghx = 12 <br/>ElseIf ghx = "D" Then <br/>ghx = 13 <br/>ElseIf ghx = "E" Then <br/>ghx = 14 <br/>ElseIf ghx = "F" Then <br/>ghx = 15 <br/>End If <br/>get_hxno = ghx <br/>End Function </p><p>randomize <br/>num = int(7999*rnd+2000) '计数器的值 <br/>num2 = EncryptString(num) <br/>session("Loginnum")=num <br/>%> <br/>document.write("<img src='/verify/count.asp?sksid=<%=num2%>'>") ' 这里是调用图片的路径 </p><p>count.asp </p><p><br/><!--#include file="numimg.asp"--> </p><p><% <br/>'### To encrypt/decrypt include this code in your page <br/>'### strMyEncryptedString = EncryptString(strString) <br/>'### strMyDecryptedString = DeCryptString(strMyEncryptedString) <br/>'### You are free to use this code as long as credits remain in place <br/>'### also if you improve this code let me know. </p><p> rivate Function EncryptString(strString) <br/>'#################################################################### <br/>'### Crypt Function ? 2001 by Slavic Kozyuk grindkore@yahoo.com ### <br/>'### Arguments: strString <--- String you wish to encrypt ### <br/>'### Output: Encrypted HEX string ### <br/>'#################################################################### </p><p>Dim CharHexSet, intStringLen, strTemp, strRAW, I, intKey, intOffSet <br/>Randomize Timer </p><p>intKey = Round((RND * 1000000) + 1000000) '##### Key Bitsize <br/>intOffSet = Round((RND * 1000000) + 1000000) '##### KeyOffSet Bitsize </p><p>If IsNull(strString) = False Then <br/>strRAW = strString <br/>intStringLen = Len(strRAW) </p><p>For i = 0 to intStringLen - 1 <br/>strTemp = Left(strRAW, 1) <br/>strRAW = Right(strRAW, Len(strRAW) - 1) <br/>CharHexSet = CharHexSet & Hex(Asc(strTemp) * intKey)& Hex(intKey) <br/>Next </p><p>EncryptString = CharHexSet & "|" & Hex(intOffSet + intKey) & "|" & Hex(intOffSet) <br/>Else <br/>EncryptString = "" <br/>End If <br/>End Function </p><p></p><p><br/> rivate Function DeCryptString(strCryptString) <br/>'#################################################################### <br/>'### Crypt Function ? 2001 by Slavic Kozyuk grindkore@yahoo.com ### <br/>'### Arguments: Encrypted HEX stringt ### <br/>'### Output: Decrypted ASCII string ### <br/>'#################################################################### <br/>'### Note this function uses HexConv() and get_hxno() functions ### <br/>'### so make sure they are not removed ### <br/>'#################################################################### </p><p>Dim strRAW, arHexCharSet, I, intKey, intOffSet, strRawKey, strHexCrypData </p><p><br/>strRawKey = Right(strCryptString, Len(strCryptString) - InStr(strCryptString, "|")) <br/>intOffSet = Right(strRawKey, Len(strRawKey) - InStr(strRawKey,"|")) <br/>intKey = HexConv(Left(strRawKey, InStr(strRawKey, "|") - 1)) - HexConv(intOffSet) <br/>strHexCrypData = Left(strCryptString, Len(strCryptString) - (Len(strRawKey) + 1)) </p><p><br/>arHexCharSet = Split(strHexCrypData, Hex(intKey)) </p><p>For i=0 to Ubound(arHexCharSet) <br/>strRAW = strRAW & Chr(HexConv(arHexCharSet(i))/intKey) <br/>Next </p><p>DeCryptString = strRAW <br/>End Function </p><p></p><p> rivate Function HexConv(hexVar) <br/>Dim hxx, hxx_var, multiply <br/>IF hexVar <> "" THEN <br/>hexVar = UCASE(hexVar) <br/>hexVar = StrReverse(hexVar) <br/>DIM hx() <br/>REDIM hx(LEN(hexVar)) <br/>hxx = 0 <br/>hxx_var = 0 <br/>FOR hxx = 1 TO LEN(hexVar) <br/>IF multiply = "" THEN multiply = 1 <br/>hx(hxx) = mid(hexVar,hxx,1) <br/>hxx_var = (get_hxno(hx(hxx)) * multiply) + hxx_var <br/>multiply = (multiply * 16) <br/>NEXT <br/>hexVar = hxx_var <br/>HexConv = hexVar <br/>END IF <br/>End Function </p><p> rivate Function get_hxno(ghx) <br/>If ghx = "A" Then <br/>ghx = 10 <br/>ElseIf ghx = "B" Then <br/>ghx = 11 <br/>ElseIf ghx = "C" Then <br/>ghx = 12 <br/>ElseIf ghx = "D" Then <br/>ghx = 13 <br/>ElseIf ghx = "E" Then <br/>ghx = 14 <br/>ElseIf ghx = "F" Then <br/>ghx = 15 <br/>End If <br/>get_hxno = ghx <br/>End Function </p><p><br/>%> </p> |
|