WEB上的“校验码”(图)是生成原理是什么?

ANSARS 2004-12-05 09:06:20
现在CSDN.NET也用“校验码”(图)了,有的网站(如HOTMAIL)用的“校验码”是不规则字体,这些“校验码”(图)是怎么生成的?
...全文
398 点赞 收藏 20
写回复
20 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
leenioa 2010-06-25
那个是用GDI+自动生成的
应该是用的字体不一样吧
回复
molocha 2005-03-08
qq垃圾,竟然用中文,顶区个肺!不会打中文怎么办,麻烦死了!!
回复
Mapleleaf123 2005-03-07
我喜歡註冊qq時的驗證,哪個會
回复
sbq79 2005-03-07
用十个失去意义了。还不如取消
回复
尚和空四 2005-03-07
十个图能够满足需要吗
回复
sadxu 2005-03-07
用十个图不能够满足需要吗???为什么用100000个呢???
回复
hbhbhbhbhb1021 2005-03-07
注意XP如果安装了SP2是不能显示ASP写的有些验证码的,要修改下注册表,具体怎么改,到GOOGLE上搜下,好多教的
回复
jarraytan 2005-03-07
就用随机数加session得了,简单易行。

做那么花哨有必要吗?
回复
jarraytan 2005-03-07
QQ注册时采用中文验证码了。。。
回复
ygjwjj 2005-03-07
数字的验证码早就不希奇了,现在都是带字体的中文验证码!
回复
尚和空四 2005-03-07
回复
dsclub 2004-12-06
还是DotNet好,可以直接使用GDI/GDI+。

如果是ASP呢:
1、利用COM(论坛里记得三角猫大哥做过)
2、还有就是自己提前把一个图片文件按文档格式拆好了,最后再用ASP,以流的方式生成数据,让这个页面以image方式下载到客户端。(记不太清了,动网好像是这么做的)
回复
silklove 2004-12-06
这是我刚刚用C#下的:
public System.IO.MemoryStream RndBitmap()
{//产生四位随机字母和数字,并将其写入Bitmap中
string strMother="ABCDEFGHIJKLMNPQRSTUVWXYZ23456789";//去除了1,数字0,字母O
string rt="";
System.Random rnd=new Random((int)System.DateTime.Now.Millisecond);
for(int i=0;i<4;i++)
rt+=strMother.Substring(rnd.Next(0,strMother.Length),1);
Session["vcode"]=rt;
vcode=(string)Session["vcode"];
Bitmap bt=new Bitmap(58,22);
bt.MakeTransparent(Color.White);
Graphics gr=Graphics.FromImage(bt);
gr.DrawString(rt,(new Font("宋体",16,FontStyle.Bold)),(new SolidBrush(Color.FromArgb(rnd.Next(200),rnd.Next(200),rnd.Next(200)))),0,0);
for(int j=0;j<80;j++)//随机产生80个点
bt.SetPixel(rnd.Next(0,58),rnd.Next(0,22),Color.FromArgb(rnd.Next(0,255),rnd.Next(0,255),rnd.Next(0,255)));
System.IO.MemoryStream ms=new System.IO.MemoryStream();
bt.Save(ms,System.Drawing.Imaging.ImageFormat.Png);
return ms;
}
回复
liuyangxuan 2004-12-06
臭兔子。
回复
ygjwjj 2004-12-06
<%
Response.Buffer = True
With Response
.Expires = -1
.AddHeader "Pragma","no-cache"
.AddHeader "cache-ctrol","no-cache"
End With
Dim a(10,10)

a(0,1) = "0x3c" '数字0
a(0,2) = "0x66"
a(0,3) = "0xc3"
a(0,4) = "0xc3"
a(0,5) = "0xc3"
a(0,6) = "0xc3"
a(0,7) = "0xc3"
a(0,8) = "0xc3"
a(0,9) = "0x66"
a(0,10)= "0x3c"

a(1,1) = "0x18" '数字1
a(1,2) = "0x1c"
a(1,3) = "0x18"
a(1,4) = "0x18"
a(1,5) = "0x18"
a(1,6) = "0x18"
a(1,7) = "0x18"
a(1,8) = "0x18"
a(1,9) = "0x18"
a(0,10)= "0x7e"

a(2,1) = "0x3c" '数字2
a(2,2) = "0x66"
a(2,3) = "0x60"
a(2,4) = "0x60"
a(2,5) = "0x30"
a(2,6) = "0x18"
a(2,7) = "0x0c"
a(2,8) = "0x06"
a(2,9) = "0x06"
a(2,10)= "0x7e"

a(3,1) = "0x3c" '数字3
a(3,2) = "0x66"
a(3,3) = "0xc0"
a(3,4) = "0x60"
a(3,5) = "0x1c"
a(3,6) = "0x60"
a(3,7) = "0xc0"
a(3,8) = "0xc0"
a(3,9) = "0x66"
a(3,10)= "0x38"

a(4,1) = "0x38" '数字4
a(4,2) = "0x3c"
a(4,3) = "0x36"
a(4,4) = "0x33"
a(4,5) = "0x33"
a(4,6) = "0x33"
a(4,7) = "0xff"
a(4,8) = "0x30"
a(4,9) = "0x30"
a(4,10)= "0xfe"

a(5,1) = "0xfe" '数字5
a(5,2) = "0xfe"
a(5,3) = "0x06"
a(5,4) = "0x06"
a(5,5) = "0x3e"
a(5,6) = "0x60"
a(5,7) = "0xc0"
a(5,8) = "0xc3"
a(5,9) = "0x66"
a(5,10)= "0x3c"

a(6,1) = "0x60" '数字6
a(6,2) = "0x30"
a(6,3) = "0x18"
a(6,4) = "0x0c"
a(6,5) = "0x3e"
a(6,6) = "0x63"
a(6,7) = "0xc3"
a(6,8) = "0xc3"
a(6,9) = "0x66"
a(6,10) ="0x3c"

a(7,1) = "0xff" '数字7
a(7,2) = "0xc0"
a(7,3) = "0x60"
a(7,4) = "0x30"
a(7,5) = "0x18"
a(7,6) = "0x18"
a(7,7) = "0x18"
a(7,8) = "0x18"
a(7,9) = "0x18"
a(7,10)= "0x18"

a(8,1) = "0x3c" '数字8
a(8,2) = "0x66"
a(8,3) = "0xc3"
a(8,4) = "0x66"
a(8,5) = "0x3c"
a(8,6) = "0x66"
a(8,7) = "0xc3"
a(8,8) = "0xc3"
a(8,9) = "0x66"
a(8,10)= "0x3c"

a(9,1) = "0x3c" '数字9
a(9,2) = "0x66"
a(9,3) = "0xc3"
a(9,4) = "0xc3"
a(9,5) = "0x66"
a(9,6) = "0x3c"
a(9,7) = "0x18"
a(9,8) = "0x0c"
a(9,9) = "0x06"
a(9,10)= "0x03"
Dim num
Randomize
num = Int(7999 * Rnd + 2000)
Session("safenum") = num
Dim Image
Dim Width, Height
Dim digtal
Dim Length
Dim sort
Dim hc
Length = 4
hc = chr(13) & chr(10)
Redim sort(Length)
digital = ""
For I = 1 To Length - Len(num)
digital = digital & "0"
Next
For I = 1 To Len(num)
digital = digital & Mid(num, I, 1)
Next
For I = 1 To Len(digital)
sort(I) = Mid(digital, I, 1)
Next
Width = 8 * Len(digital)
Height = 10
Response.ContentType = "image/x-xbitmap"
Image = "#define counter_width " & Width & hc
Image = Image & "#define counter_height " & Height & hc
Image = Image & "static unsigned char counter_bits[] = {" & hc
For I = 1 To Height
For J = 1 To Length
Image = Image & a(sort(J),I) & ","
Next
Next
Image = Left(Image, Len(Image) - 1)
Image = Image & "};" & hc
Response.Write Image
%>
回复
ANSARS 2004-12-06
h2yang(小青) :你的办法我想到了,是万不得已。有好的方法吗?
回复
h2yang 2004-12-05
如果是我,用最笨的办法:用10000个图,用一个随机数,再<img src="">就可以了……
回复
lovebanyi 2004-12-05
随机数 加一个session就可以实现了
已前是好几个图片拼的,,现在是用一个图片的,,
回复
3573745 2004-12-05
凑合用就是了!
某些东西没必要懂那么多!
回复
***************************************************************
' ************************** ASPCanvas **************************
' ***************************************************************
'
' Drawing and presentation object for ASP
'
' Chris Read (aka Centurix/askdaquack/captainscript)
'
' Thanks to Richard Deeming (www.trinet.co.uk) for improving
' the arc drawing algorithm
' Thanks to Daniel Hasan for bezier curve adjustments
' Thanks to Tony Stefano for his extra font packs
'
' Updated 23/02/2003
'
' ASPCanvas home: http://users.bigpond.net.au/mrjolly/
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-12-05 09:06
社区公告
暂无公告