最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP实现加法验证码方法
时间:2022-09-16 编辑:坚强 来源:一聚教程网
今天小编为大家带来了关于ASP实现加法验证码方法,本文用非常详细的介绍和代码呈现给大家,感兴趣的小伙伴记得点击关注哦。
将验证码改为加法运算,比如验证码显示“25+64等于?”,那么输入“91”就能通过验证。
来看看效果图对比:字符验证码: → 加法验证码:
优点:
①与纯字符验证码相比,本程序效防止了绝大部分(99%以上)广告机的自动识别。即使是中文验证码, 也能被市面上的部分广告机识别。
②与中文验证码相比,避免了用户输入用户名密码验证码的时候需要切换输入法的麻烦。
说明:该程序需要网站空间支持ASPJpeg组件、楷体_GB2312字体。
代码如下:
<% Const FontColor = &H000000 ' 字体颜色 Const BgColor = &HFFCCFF ' 背景颜色 Call CreatValidCode("GetCode") Sub CreatValidCode(pSN) Dim x, 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)) Set Jpeg = Server.CreateObject("Persits.Jpeg") Jpeg.New 100,20,BgColor Jpeg.Quality=100 With Jpeg.Canvas .Font.Bold = True .Font.Size = 16 .Font.Rotation = 0 .Font.Family = "楷体_GB2312" .Font.Color = FontColor .PrintText 4, 3, CStr(x(0)) .PrintText 14, 3, CStr(x(1)) .PrintText 26, 3, x(6) .PrintText 38, 3, CStr(x(2)) .PrintText 48, 3, CStr(x(3)) .Font.Rotation = 15 .PrintText 55, 3, "等" .PrintText 70, 3, "于" .PrintText 85, 3, "?" End With '禁止缓存 Response.ContentType = "image/jpeg" Response.Expires = -9999 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-ctrol", "no-cache" Response.AddHeader "Content-Disposition","inline; filename=vcode.jpg" Jpeg.SendBinary Jpeg.Close Set Jpeg = Nothing End Sub %>
以上就是关于asp实现加法验证码的关键代码,有兴趣的朋友,还可以扩展为其他的运算,比如乘法,减法,乘方等,希望本文对大家的学习有所帮助。
-
上一个: ASP错误捕获的几种常规处理方法介绍
-
下一个: 如何封装一个Ajax函数介绍
相关文章
- ASP错误捕获的几种常规处理方法介绍 09-16
- asp中获取日期为星期几的技巧 09-14
- Asp编码优化参考 09-14
- .Net Core认证系统源码解析 12-26
- SharePoint Server 2019新特性介绍 01-15
- 在Raspberry Pi上构建Docker 1.12步骤详解 08-17