這篇文章主要介紹了ASP實現加法驗證碼,是在原來的驗證碼基礎上進行創新,將驗證碼改為加法運算,感興趣的小伙伴們可以參考一下
將驗證碼改為加法運算,比如驗證碼顯示25+64等於? ,那麼輸入91就能通過驗證。
來看看效果圖對比:字符驗證碼:→ 加法驗證碼:
優點:
①與純字符驗證碼相比,本程序效防止了絕大部分(99%以上)廣告機的自動識別。即使是中文驗證碼, 也能被市面上的部分廣告機識別。
②與中文驗證碼相比,避免了用戶輸入用戶名密碼驗證碼的時候需要切換輸入法的麻煩。
說明:該程序需要網站空間支持ASPJpeg組件、楷體_GB2312字體。
代碼如下:
?
- <%
- ConstFontColor=&H000000'字體顏色
- ConstBgColor=&HFFCCFF'背景顏色
- CallCreatValidCode(GetCode)
- SubCreatValidCode(pSN)
- Dimx,Jpeg
- Randomize
- x=Array(1+Int(Rnd()*9),Int(Rnd()*10),1+Int(Rnd()*9),Int(Rnd()*10),0,0,+)
- x(4)=x(0)*10+x(1)
- x(5)=x(2)*10+x(3)
- 'Session(pSN)=CStr(Eval(x(4)&x(6)&x(5)))
- Session(pSN)=CStr(x(4)+x(5))
- SetJpeg=Server.CreateObject(Persits.Jpeg)
- Jpeg.New100,20,BgColor
- Jpeg.Quality=100
- WithJpeg.Canvas
- .Font.Bold=True
- .Font.Size=16
- .Font.Rotation=0
- .Font.Family=楷體_GB2312
- .Font.Color=FontColor
- .PrintText4,3,CStr(x(0))
- .PrintText14,3,CStr(x(1))
- .PrintText26,3,x(6)
- .PrintText38,3,CStr(x(2))
- .PrintText48,3,CStr(x(3))
- .Font.Rotation=15
- .PrintText55,3,等
- .PrintText70,3,於
- .PrintText85,3,?
- EndWith
- '禁止緩存
- Response.ContentType=image/jpeg
- Response.Expires=-9999
- Response.AddHeaderpragma,no-cache
- Response.AddHeadercache-ctrol,no-cache
- Response.AddHeaderContent-Disposition,inline;filename=vcode.jpg
- Jpeg.SendBinary
- Jpeg.Close
- SetJpeg=Nothing
- EndSub
- %>