asp下的一个很简单的验证码程序第13页

2018-09-06 13:22

阅读:776

  主程序共三个

我的调用方式<scriptlanguage=javascriptsrc=/verify/num.asp></script>
验证方式iftrim(Loginnum)<>trim(session(Loginnum))then
Response.WriteError(验证码错误!)
Response.End
endif


num.asp

<%
###Toencrypt/decryptincludethiscodeinyourpage
###strMyEncryptedString=EncryptString(strString)
###strMyDecryptedString=DeCryptString(strMyEncryptedString)
###Youarefreetousethiscodeaslongascreditsremaininplace
###alsoifyouimprovethiscodeletmeknow.

PrivateFunctionEncryptString(strString)
####################################################################
###Arguments:strString<---Stringyouwishtoencrypt###
###Output:EncryptedHEXstring###
####################################################################

DimCharHexSet,intStringLen,strTemp,strRAW,I,intKey,intOffSet
RandomizeTimer

intKey=Round((RND*1000000)+1000000)#####KeyBitsize
intOffSet=Round((RND*1000000)+1000000)#####KeyOffSetBitsize

IfIsNull(strString)=FalseThen
strRAW=strString
intStringLen=Len(strRAW)

Fori=0tointStringLen-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=
EndIf
EndFunction



PrivateFunctionDeCryptString(strCryptString)
####################################################################
###Arguments:EncryptedHEXstringt###
###Output:DecryptedASCIIstring###
####################################################################
###NotethisfunctionusesHexConv()andget_hxno()functions###
###somakesuretheyarenotremoved###
####################################################################

DimstrRAW,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))

Fori=0toUbound(arHexCharSet)
strRAW=strRAW&Chr(HexConv(arHexCharSet(i))/intKey)
Next

DeCryptString=strRAW
EndFunction


PrivateFunctionHexConv(hexVar)
Dimhxx,hxx_var,multiply
IFhexVar<>THEN
hexVar=UCASE(hexVar)
hexVar=StrReverse(hexVar)
DIMhx()
REDIMhx(LEN(hexVar))
hxx=0
hxx_var=0
FORhxx=1TOLEN(hexVar)
IFmultiply=THENmultiply=1
hx(hxx)=mid(hexVar,hxx,1)
hxx_var=(get_hxno(hx(hxx))*multiply)+hxx_var
multiply=(multiply*16)
NEXT
hexVar=hxx_var
HexConv=hexVar
ENDIF
EndFunction

PrivateFunctionget_hxno(ghx)
Ifghx=AThen
ghx=10
ElseIfghx=BThen
ghx=11
ElseIfghx=CThen
ghx=12
ElseIfghx=DThen
ghx=13
ElseIfghx=EThen
ghx=14
ElseIfghx=FThen
ghx=15
EndIf
get_hxno=ghx
EndFunction

randomize
num=int(7999*rnd+2000)计数器的值
num2=EncryptString(num)
session(Loginnum)=num
%>
document.write(<imgsrc=/verify/count.asp?sksid=<%=num2%>>)这里是调用图片的路径

count.asp
123下一页阅读全文


评论


亲,登录后才可以留言!