ASP生成彩色可变长验证码程序
2008-02-23 09:43:57来源:互联网 阅读 ()
本验证码生成程序特点如下:
一、彩色;
二、BMP 图像色深为 16 位,生成的图片体积更小;(4位长的验证码只有几百字节)
三、长度可自定义;(1位至25位可固定设置,也可以自己改成动态)
四、背景杂色深度可自定义;
具体请看代码
注:代码中并没有针对动网的 设置验证码 Session 的地方。想用的朋友自己根据需要改一下,位置就在代码中出现 Session("Num") 的那一行,改成自己需要的名称就可以了。这个验证码也可以用在任何需要验证码的地方。不用在动网论坛也可。
下面是代码部分:
<--r>Option Explicit
Response.Expires = 0
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
Response.ContentType = "Image/BMP"
Randomize Timer
Dim Text_Data(9),Text_Len,Int_Temp(),I,j,k,Int_Temp2
''***** 参数配置区 *****
Text_Len = 4 ''验证码长度(支持1-25位)
''**********************
ReDim Int_Temp( Text_Len - 1 )
Text_Data(0) = "00000000000001111000001100110000110111000011011100001100110000111011000011101100001100110000011110000000000000"
Text_Data(1) = "00000000000000011000000011100000111110000000011000000001100000000110000000011000000001100000000110000000000000"
Text_Data(2) = "00000000000001111000001100110000110011000000001100000001100000001100000001100000001100000000111111000000000000"
Text_Data(3) = "00000000000001111000001100110000110011000000001100000011100000000011000011001100001100110000011110000000000000"
Text_Data(4) = "00000000000001100000000110000000011011000001101100000110110000110011000011111110000000110000000011000000000000"
Text_Data(5) = "00000000000011111100001100000000110000000011000000001111100000000011000000001100000001100000111100000000000000"
Text_Data(6) = "00000000000000111000000011000000011000000011111000001100110000110011000011001100001100110000011110000000000000"
Text_Data(7) = "00000000000011111100000000110000000110000000011000000011000000001100000001100000000110000000011000000000000000"
Text_Data(8) = "00000000000001111000001100110000110011000011101100000111100000110111000011001100001100110000011110000000000000"
Text_Data(9) = "00000000000001111000001100110000110011000011001100001100110000011111000000011000000011000000011100000000000000"
''下面随机生成各位验证码
Session("Num") = ""
For I = 0 To Text_Len - 1
Int_Temp(I) = Int(Rnd * 10)
Session("Num") = Session("Num") Mid("0123456789",Int_Temp(I) 1,1)
Next
''下面输出文件头部分
Int_Temp2 = (Text_Len - 1) \ 4 * 220 ((Text_Len - 1) / 4 - (Text_Len - 1) \ 4 * 4) * 44
Response.BinaryWrite ChrB(&H42) & ChrB(&H4D)
Response.BinaryWrite ChrB(((Int_Temp2 206) / 256 - (Int_Temp2 206) \ 256) * 256) & ChrB((Int_Temp2 206) \ 256) ''特殊位
Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H76) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H28) & ChrB(0) & ChrB(0) & ChrB(0)
Response.BinaryWrite ChrB(Text_Len * 10) ''特殊位
Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&HB) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H1) & ChrB(0) & ChrB(&H4) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0)
Response.BinaryWrite ChrB(((Int_Temp2 88) / 256 - (Int_Temp2 88) \ 256) * 256) & ChrB((Int_Temp2 88) \ 256) ''特殊位
Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(16) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(16) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(&H80) & ChrB(0) & ChrB(&H80) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(0) & ChrB(&H80) & ChrB(0)
Response.BinaryWrite ChrB(&H80) & ChrB(&H80) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(&H80) & ChrB(&H80) & ChrB(0) & ChrB(&HC0) & ChrB(&HC0) & ChrB(&HC0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(&HFF) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(&HFF) & ChrB(&HFF) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(&HFF) & ChrB(&HFF) & ChrB(0)
''下面输出图片数据
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇:ASP漏洞解析及黑客防范法
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash