动网论坛教程:重新修改过的验证码生成程序
2010-07-22 18:58:41 来源:WEB开发网下面的程序是我修改过的验证码生成程序,需要AspJpeg支持,不过可以灵活的修改字体和背景干扰线,能够比较有效次对付OCR
<%
Option Explicit
Response.buffer=true
Call Com_CreatValidCode("GetCode")
Sub Com_CreatValidCode(pSN)
'Author: 战鹰
'QQ: 280147559
'E-mail: zhanying At QBQ Dot CN
' 禁止缓存
Response.Expires = -9999
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
''Response.ContentType = "Image/BMP"
Randomize
Dim i, ii, iii
dim vCodes
For i = 0 To 3 '生成4位数字
vCodes = vCodes &Int(Rnd * 10)
Next
Session(pSN) = vCodes
'response.write vCodes
Dim Jpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")
'response.write vCodes
Jpeg.New 50,20,"&H000000" '设置图片的宽,高背景颜色
Jpeg.Canvas.Font.Color = "&HFFFFFF" '设置字体颜色
Jpeg.Canvas.Font.Family = "Arial Bold" '设置字体
Jpeg.Canvas.Font.Bold = True '是否是粗体
Jpeg.Canvas.Font.Size = 24 '字号
Jpeg.Canvas.print 3,-2,vCodes '输出的初始位置
Jpeg.Canvas.Pen.Color="&HFFFFFF" '背景格线的颜色
Jpeg.Canvas.Pen.Width=1 '格线的粗细
更多精彩
赞助商链接