·您的位置: 首页 » 资源教程 » 编程开发 » ASP » ASP彩色验证码图像生成脚本

ASP彩色验证码图像生成脚本

类别: ASP教程  评论数:0 总得分:0
ADODE.Stream完成!49行代码,三个文件 ,有点象本站的CGI img.exe的效果
Asp文件:Code.Asp
数据文件:body.Fix , Head.Fix
用法:<img src="code.asp">
在检验页:判断 Cint(request("GetCode"))=Session("GetCode")
:rolleyes: :rolleyes: :rolleyes:
别怪我做多余劳动~~折腾代码!写个全新的的东东是惬意的~~
请注意下载完整的数字数据文件~~

代码思路就是利用 ADODB.Stream二进制对象进行二进制流的处理!
将随机生成的数字转换为调用图像数据中相应的数据块,图像数据是GBR GBR ..排部的 数据,头是BMP的头~~然后用ADODB.Stream 将生成的随机数字图像数据再组合为新的一个bmp图像块~~用Response.BinaryWrite 将其直接发送浏览器

Body.Fix 数字0~9 10X100竖排的RGB阵列数据3200 byte
Head.Fix 是54byte的BMP头
如果要改变字体和颜色~~可以将bmp 10x100 图像的前54字节去掉!
替换body.Fix文件

[code]
<%
Option explicit
Response.buffer=true
NumCode
Function NumCode()
Response.Expires = -1
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-ctrol","no-cache"
dim zNum,i,j
dim Ados,Ados1
Randomize timer
zNum = cint(8999*Rnd+1000)
Session("GetCode") = zNum
dim zimg(4),NStr
NStr=cstr(zNum)
For i=0 to 3
zimg(i)=cint(mid(NStr,i+1,1))
Next
dim Pos
set Ados=Server.CreateObject("Adodb.Stream")
Ados.Mode=3
Ados.Type=1
Ados.Open
set Ados1=Server.CreateObject("Adodb.Stream")
Ados1.Mode=3
Ados1.Type=1
Ados1.Open
Ados.LoadFromFile(Server.mappath("body.Fix"))
Ados1.write Ados.read(1280)
for i=0 to 3
Ados.Position=(9-zimg(i))*320
Ados1.Position=i*320
Ados1.write ados.read(320)
next
Ados.LoadFromFile(Server.mappath("head.fix"))
Pos=lenb(Ados.read())
Ados.Position=Pos
for i=0 to 9 step 1
for j=0 to 3
Ados1.Position=i*32+j*320
Ados.Position=Pos+30*j+i*120
Ados.write ados1.read(30)
next
next
Response.ContentType = "image/BMP"
Ados.Position=0
Response.BinaryWrite Ados.read()
Ados.Close:set Ados=nothing
Ados1.Close:set Ados1=nothing
End Function
\'Asp code Created by BlueIdea.COM Web Team V37 2003-7-25
%>
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1