随机数字直接生成图片的ASP代码

随机数字直接生成图片的ASP代码,可以做认证码。
xbm.asp
<!--#include file="numcode.asp"-->
<%
Response.Buffer = True
With Response
.Expires = -1
.AddHeader "Pragma","no-cache"
.AddHeader "cache-ctrol","no-cache"
End With

Dim num
Randomize
num = Int(7999 * Rnd + 2000)
Session("validateCode") = 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
%>

numcode.asp
<%
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"
%>

引用时,和插入图片一样
<img src="xbm.asp">

 

时间: 2024-11-01 21:32:45

随机数字直接生成图片的ASP代码的相关文章

使用ASP生成包含随机数字的图片

随机|随机数字 文件一.xbm.asp <!--#includefile="numcode.asp"--><%Response.Buffer=TrueWithResponse .Expires=-1 .AddHeader"Pragma","no-cache" .AddHeader"cache-ctrol","no-cache"EndWith DimnumRandomizenum=Int(7

isnumeric检测是否为数字类型的asp代码_应用技巧

ASP判断是否为数字通常用isnumeric()函数,它的作用是判断里面的参数表达式是不是数值,用法:IsNumeric(内容),如果"内容"最终运算结果为数字,则 IsNumeric 返回 True:否则返回 False.如果 expression 是日期表达式,则 IsNumeric 返回 False. ASP判断是否为数字的具体例子: 复制代码 代码如下: <% if isNumeric(内容)  then Response.Write("是数字") e

jquery输入数字随机抽奖特效的简单实现代码_jquery

简介:jQuery自定义数值抽奖活动代码是一款点击开始按钮计算机会产生玩家输入范围内的随机数,点击停止按钮,将显示数字最终结果的效果. 效果图如下: 代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jQuery自定义数值抽奖活动代码 - </title><base target="_blank" />

isnumeric检测是否为数字类型的asp代码

ASP判断是否为数字通常用isnumeric()函数,它的作用是判断里面的参数表达式是不是数值,用法:IsNumeric(内容),如果"内容"最终运算结果为数字,则 IsNumeric 返回 True:否则返回 False.如果 expression 是日期表达式,则 IsNumeric 返回 False. ASP判断是否为数字的具体例子: 复制代码 代码如下: <% if isNumeric(内容)  then Response.Write("是数字") e

asp生成一个不重复的随机数字

随机|随机数字|重复   Sub CalCaPiao() Dim strCaiPiaoNoArr() As String Dim strSQL As String Dim strCaiPiaoNo As String strCaiPiaoNo = "01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33" Dim StrTempArr(7) As

php随机数字代码

  今天,有朋友咨询烈火PHP随机数字的问题,这是PHP的基础问题,大家可以参考一下烈火提供的PHP手册,由于时间关系,小编也懒的写,在网上找了一些例子,综合在一起,希望对大家有所帮助吧,如有问题请在下面说出来. //seed用户自定义函数以微秒作为种子 function seed() { list($msec, $sec) = explode(' ', microtime()); return (float) $sec; } //播下随机数发生器种子,用srand函数调用seed函数的返回结果

Access与Sql Server之ASP代码比较

access|server|sql|比较 后台数据库: [Microsoft Access] 与 [Microsoft Sql Server] 更换之后,ASP代码应注意要修改的一些地方: [一]连接问题(举例) [Microsoft Access] constr = "DBQ=c:\data\clwz.mdb; DRIVER={Microsoft Access Driver (*.mdb)}" [Microsoft Sql Server] constr = "DRIVER=

技巧:Access与Sql Server之ASP代码比较

access|server|sql|比较|技巧 后台数据库: [Microsoft Access] 与 [Microsoft Sql Server] 更换之后,ASP代码应注意要修改的一些地方: [一]连接问题(举例) [Microsoft Access] constr = "DBQ=c:\data\clwz.mdb; DRIVER={Microsoft Access Driver (*.mdb)}" [Microsoft Sql Server] constr = "DRIV

值得收藏的一些ASP代码

值得收藏的一些ASP代码值得收藏的一些ASP代码1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键<table border oncontextmenu=return(false)><td>no</table> 可用于Table2. <body onselectstart="return false"> 取消选取.防止复制3. onpaste=&quo