一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

加入杂点象素asp验证码生成程序

时间:2022-06-30 09:13:10 编辑:袖梨 来源:一聚教程网

call createsafecode()   '调用createsafecode过程
sub createsafecode()   '定义createsafecode过程
 'addheader方法用于增加带有一个要发送到客户应用程序的特殊的http头
 response.addheader "pragma","no-cache"
 response.addheader "cache-ctrol","no-cache"
 '指定响应的http 内容类型为"image/bmp"
 response.contenttype="image/bmp"
 '生成随机数,因为rnd 生成一个小于1但大于或等于0的数,所以8999*rnd+1000得到的
 '随机数为一个四位数
 randomize timer
 safecode=cint(8999*rnd+1000)
 '将safecode保存在sessioncode("safecode")中
 session("safecode")=safecode
 '定义一个二维数组,保存字符数据
 dim letter(10,20)
 
 '要显示的字符"0"
 letter(0,0)="0000000000000000"
 letter(0,1)="0000111110000000"
 letter(0,2)="0001111111000000"
 letter(0,3)="0011100011100000"
 letter(0,4)="0011000001110000"
 letter(0,5)="0111000000110000"
 letter(0,6)="0110000000111000"
 letter(0,7)="0110000000111000"
 letter(0,8)="1110000000111000"
 letter(0,9)="1100000000111000"
 letter(0,10)="1100000000111000"
 letter(0,11)="1110000000111000"
 letter(0,12)="1110000000110000"
 letter(0,13)="1110000000110000"
 letter(0,14)="0110000000110000"
 letter(0,15)="0111000001110000"
 letter(0,15)="0011100001100000"
 letter(0,16)="0001111111000000"
 letter(0,17)="0000111110000000"
 letter(0,18)="0000000000000000"
 letter(0,19)="0000000000000000"
 
 '要显示的字符"1"
 letter(1,0)="0000000000000000"
 letter(1,1)="0000000111000000"
 letter(1,2)="0000000111000000"
 letter(1,3)="0000001110000000"
 letter(1,4)="0000001100000000"
 letter(1,5)="0000001100000000"
 letter(1,6)="0000001100000000"
 letter(1,7)="0000011100000000"
 letter(1,8)="0000011100000000"
 letter(1,9)="0000011100000000"
 letter(1,10)="0000011000000000"
 letter(1,11)="0000011000000000"
 letter(1,12)="0000011000000000"
 letter(1,13)="0000011000000000"
 letter(1,14)="0000011000000000"
 letter(1,15)="0000011000000000"
 letter(1,16)="0000011000000000"
 letter(1,17)="0000001000000000"
 letter(1,18)="0000000000000000"
 letter(1,19)="0000000000000000"
 '要显示的字符"2"
 letter(2,0)="0000000000000000"
 letter(2,1)="0000111111000000"
 letter(2,2)="0001111111100000"
 letter(2,3)="0011100001110000"
 letter(2,4)="0111000001110000"
 letter(2,5)="0111000001100000"
 letter(2,6)="0110000001100000"
 letter(2,7)="0000000011100000"
 letter(2,8)="0000000111000000"
 letter(2,9)="0000000111000000"
 letter(2,10)="0000001100000000"
 letter(2,11)="0000011100000000"
 letter(2,12)="0000111000000000"
 letter(2,13)="0001100000000000"
 letter(2,14)="0001100000000000"
 letter(2,15)="0011000001110000"
 letter(2,16)="0110111111110000"
 letter(2,17)="0111111111111000"
 letter(2,18)="0111110000000000"
 letter(2,19)="0000000000000000"

 '要显示的字符"3"
 letter(3,0)="0000000000000000"
 letter(3,1)="0000111111100000"
 letter(3,2)="0011111111100000"
 letter(3,3)="0111000011110000"
 letter(3,4)="0110000001100000"
 letter(3,5)="0100000011100000"
 letter(3,6)="0000000011100000"
 letter(3,7)="0000000111000000"
 letter(3,8)="0000001100000000"
 letter(3,9)="0000011111000000"
 letter(3,10)="0000010011100000"
 letter(3,11)="0000000001110000"
 letter(3,12)="0000000001110000"
 letter(3,13)="0000000001110000"
 letter(3,14)="0000000001110000"
 letter(3,15)="0000000001100000"
 letter(3,16)="1110000011100000"
 letter(3,17)="1111111111000000"
 letter(3,18)="0111111110000000"
 letter(3,19)="0000000000000000"

 '要显示的字符"4"
 letter(4,0)="0000000000000000"
 letter(4,1)="0000000011100000"
 letter(4,2)="0000000111100000"
 letter(4,3)="0000001110000000"
 letter(4,4)="0000011101110000"
 letter(4,5)="0000111001110000"
 letter(4,6)="0000110001100000"
 letter(4,7)="0001100011100000"
 letter(4,8)="0011100011000000"
 letter(4,9)="0111000011000000"
 letter(4,10)="0110000011000000"
 letter(4,11)="0110000011000000"
 letter(4,12)="1100011111111000"
 letter(4,13)="1111111111110000"
 letter(4,14)="1111111110000000"
 letter(4,15)="1110000110000000"
 letter(4,16)="0000000111000000"
 letter(4,17)="0000000011000000"
 letter(4,18)="0000000011000000"
 letter(4,19)="0000000010000000"

 '要显示的字符"5"
 letter(5,0)="0000000000000000"
 letter(5,1)="0000110000010000"
 letter(5,2)="0001111111111000"
 letter(5,3)="0001111111110000"
 letter(5,4)="0001111000000000"
 letter(5,5)="0001100000000000"
 letter(5,6)="0011100000000000"
 letter(5,7)="0011100000000000"
 letter(5,8)="0011111111000000"
 letter(5,9)="0011111111100000"
 letter(5,10)="0000000001100000"
 letter(5,11)="0000000001100000"
 letter(5,12)="0000000001100000"
 letter(5,13)="0000000001100000"
 letter(5,14)="0000000001100000"
 letter(5,15)="0000000001100000"
 letter(5,16)="0000000111100000"
 letter(5,17)="0111111111000000"
 letter(5,18)="0011111100000000"
 letter(5,19)="0000000010000000"

 '要显示的字符"6"
 letter(6,0)="0000000000000000"
 letter(6,1)="0000001111000000"
 letter(6,2)="0000011110000000"
 letter(6,3)="0000111000000000"
 letter(6,4)="0001110000000000"
 letter(6,5)="0011100000000000"
 letter(6,6)="0011000000000000"
 letter(6,7)="0011000000000000"
 letter(6,8)="0111111111000000"
 letter(6,9)="0111111111100000"
 letter(6,10)="0111000001110000"
 letter(6,11)="0110000000110000"
 letter(6,12)="0110000000110000"
 letter(6,13)="0110000000110000"
 letter(6,14)="0110000000110000"
 letter(6,15)="0111000001110000"
 letter(6,16)="0011000001110000"
 letter(6,17)="0011111111100000"
 letter(6,18)="0001111111000000"
 letter(6,19)="0000000000000000"

 '要显示的字符"7"
 letter(7,0)="0000000000000000"
 letter(7,1)="0010011111111000"
 letter(7,2)="0111111111110000"
 letter(7,3)="0111111001110000"
 letter(7,4)="0000000001100000"
 letter(7,5)="0000000011100000"
 letter(7,6)="0000000011000000"
 letter(7,7)="0000000011000000"
 letter(7,8)="0000000011000000"
 letter(7,9)="0000000111000000"
 letter(7,10)="0000000110000000"
 letter(7,11)="0000000110000000"
 letter(7,12)="0000000110000000"
 letter(7,13)="0000000110000000"
 letter(7,14)="0000001110000000"
 letter(7,15)="0000001110000000"
 letter(7,16)="0000001110000000"
 letter(7,17)="0000000100000000"
 letter(7,18)="0000000100000000"
 letter(7,19)="0000000000000000"

 '要显示的字符"8"
 letter(8,0)="0000000000000000"
 letter(8,1)="0000111111000000"
 letter(8,2)="0001111111100000"
 letter(8,3)="0011100001100000"
 letter(8,4)="0011000001100000"
 letter(8,5)="0111000001110000"
 letter(8,6)="0111000001100000"
 letter(8,7)="0011000001100000"
 letter(8,8)="0011110111100000"
 letter(8,9)="0001111111100000"
 letter(8,10)="0011100011110000"
 letter(8,11)="0111000000110000"
 letter(8,12)="0111000000110000"
 letter(8,13)="0110000000111000"
 letter(8,14)="0110000000110000"
 letter(8,15)="0110000000110000"
 letter(8,16)="0111000001110000"
 letter(8,17)="0011111111110000"
 letter(8,18)="0001111111000000"
 letter(8,19)="0000000000000000"

 '要显示的字符"9"
 letter(9,0)="0000000000000000"
 letter(9,1)="0001111111000000"
 letter(9,2)="0011111111100000"
 letter(9,3)="0111000011100000"
 letter(9,4)="0111000001110000"
 letter(9,5)="0110000000110000"
 letter(9,6)="0110000000110000"
 letter(9,7)="0110000000110000"
 letter(9,8)="0110000000110000"
 letter(9,9)="0111000001110000"
 letter(9,10)="0011111111110000"
 letter(9,11)="0001111111110000"
 letter(9,12)="0000000001100000"
 letter(9,13)="0000000001100000"
 letter(9,14)="0000000011100000"
 letter(9,15)="0000000111000000"
 letter(9,16)="0000001110000000"
 letter(9,17)="0000011100000000"
 letter(9,18)="0001111000000000"
 letter(9,19)="0000000000000000"


 '24位图
 '输出图像文件头
 'response.binarywrite chrb(66) & chrb(77) & chrb(54) & chrb(15) & chrb(0) & chrb(0) & chrb(0) & chrb(0) &  chrb(0) & chrb(0) & chrb(54) & chrb(0) & chrb(0) & chrb(0)
 '输出图像信息头
 'response.binarywrite chrb(40) & chrb(0) & chrb(0) & chrb(0) & chrb(64) & chrb(0) & chrb(0) & chrb(0) & chrb(20) & chrb(0) &  chrb(0) & chrb(0) & chrb(1) & chrb(0) &chrb(24) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(15) & chrb(0) & chrb(0) & chrb(18) & chrb(11) & chrb(0) & chrb(0) & chrb(18) & chrb(11) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0)
 '输出图像数据
 'for itemp1=19 to 0 step -1   '每一行
  'for itemp2=1 to len(safecode)   '每一个字
   'for itemp3=1 to 16   '每一个像素
    'response.binarywrite vcolordata(mid(letter(mid(safecode,itemp2,1),itemp1),itemp3,1))
   'next
  'next
 'next
 
 '显示一个8位的灰度图
 '输出图像文件头
 response.binarywrite chrb(66) & chrb(77) & chrb(54) & chrb(9) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(54) & chrb(4) & chrb(0) & chrb(0)
 '输出图像信息头
 response.binarywrite chrb(40) & chrb(0) & chrb(0) & chrb(0) & chrb(64) & chrb(0) & chrb(0) & chrb(0) & chrb(20) & chrb(0) & chrb(0) & chrb(0) & chrb(1) & chrb(0) &chrb(8) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(5) & chrb(0) & chrb(0) & chrb(18) & chrb(11) & chrb(0) & chrb(0) & chrb(18) & chrb(11) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0) & chrb(0)
 '输出图像调色板
 for i = 0 to 255
  response.binarywrite chrb(255-i) & chrb(255-i) & chrb(255-i) & chrb(0)
 next
 '输出图像数据
 for itemp1=19 to 0 step -1   '图像的每一行
  for itemp2=1 to 4   '图像上显示的每一个字
   for itemp3=1 to 16   '每个字的每一个像素
    '获得safecode第itemp2个字符,保存在safecodeper中
    safecodeper=mid(safecode,itemp2,1)
    '从字符数据letter数组中找到safecodeper对应的数组,例如1对应的数组为letter(1,0)到letter(1,19),itemp指定具体的行
    safecodeletter=letter(safecodeper,itemp1)
    '获得像素值

    '代替代码
    '图片中加入杂点象素
    pixel=mid(safecodeletter,itemp3,1)*255
    if rnd*99+1<5 then   '5为随机生成杂点的概率,可以修改
     response.binarywrite chrb(128)   '杂点的颜色为128
    else
     response.binarywrite chrb(pixel)
    end if
    '代替结束

   next
  next
 next
end sub
%>

热门栏目