当前位置:编程学习 > asp >>

用ASP生成XBM数字图片(可用来生成验证码)

答案:     XBM图片是一个纯文本的文件,可以用ASP来自动生成。可以用它来使用网站登陆的验证码;
  我们用记事本打开该文件进行分析:
  其文件结构为:
  #define counter_width 48
  #define counter_height 9
  static unsigned char counter_bits[]={7c,3c,7c,3c,70,3c,fe,7c,fe,7c,78,7c,ee,ee,ee,ee,7c,ee,e0,ee,60,ee,74,ee,70,fe,30,fe,70,fe,38,ec,e0,ec,70,ec,1c,e0,ee,e0,70,e0,fe,7e,fe,7e,70,7e,fe,3c,7c,3c,70,3c}
  文件扩展名为:.xbm
  
  #define counter_width 48 '这儿定义的是图片的宽度,一般为8的倍数
  #define counter_height 9 '这儿定义的是图片的高度,是任意的。
  static unsigned char counter_bits[]=7c,3c,7c,3c,70,3c,fe,7c,fe,7c,78,7c,ee,ee,ee,ee,7c,ee,e0,ee,60,ee,74,ee,70,fe,30,fe,70,fe,38,ec,e0,ec,70,ec,1c,e0,ee,e0,70,e0,fe,7e,fe,7e,70,7e,fe,3c,7c,3c,70,3c} '这儿是图片用来显示内容的十六进制的代码
  
  正如static unsigned char英文意思为静态的,无符号的,烧焦的。它只能用来显示黑白两种颜色。二进制中的1将来用显示为黑色,0为白色。
  
  下面为0~9数字的二进制数组(其中的图片样式仅试用于本例。如果需要别的0~9数字样式,请另自行生成)
  
  '此处声明0~9绘图用数组
  
  dim num(9,8)
  '数字0
  num(0,0)="0x38"
  num(0,1)="0x7c"
  num(0,2)="0xee"
  num(0,3)="0xee"
  num(0,4)="0xee"
  num(0,5)="0xee"
  num(0,6)="0xee"
  num(0,7)="0x7c"
  num(0,8)="0x38"
  '数字1
  num(1,0)="0x70"
  num(1,1)="0x78"
  num(1,2)="0x7c"
  num(1,3)="0x74"
  num(1,4)="0x70"
  num(1,5)="0x70"
  num(1,6)="0x70"
  num(1,7)="0x70"
  num(1,8)="0x70"
  '数字2
  num(2,0)="0x7c"
  num(2,1)="0xfe"
  num(2,2)="0xee"
  num(2,3)="0xe0"
  num(2,4)="0x70"
  num(2,5)="0x38"
  num(2,6)="0x1c"
  num(2,7)="0xfe"
  num(2,8)="0xfe"
  '数字3
  num(3,0)="0x7c"
  num(3,1)="0xfe"
  num(3,2)="0xee"
  num(3,3)="0x60"
  num(3,4)="0x30"
  num(3,5)="0xe0"
  num(3,6)="0xee"
  num(3,7)="0xfe"
  num(3,8)="0x7c"
  '数字4
  num(4,0)="0x70"
  num(4,1)="0x78"
  num(4,2)="0x7c"
  num(4,3)="0x76"
  num(4,4)="0x77"
  num(4,5)="0xff"
  num(4,6)="0xff"
  num(4,7)="0x70"
  num(4,8)="0x70"
  '数字5
  num(5,0)="0xfc"
  num(5,1)="0xfc"
  num(5,2)="0x0c"
  num(5,3)="0x7e"
  num(5,4)="0xfe"
  num(5,5)="0xe0"
  num(5,6)="0xee"
  num(5,7)="0xfe"
  num(5,8)="0x7c"
  '数字6
  num(6,0)="0x78"
  num(6,1)="0xfc"
  num(6,2)="0x0e"
  num(6,3)="0x6e"
  num(6,4)="0xfe"
  num(6,5)="0xee"
  num(6,6)="0xee"
  num(6,7)="0xfc"
  num(6,8)="0x78"
  '数字7
  num(7,0)="0xfe"
  num(7,1)="0xfe"
  num(7,2)="0x60"
  num(7,3)="0x70"
  num(7,4)="0x38"
  num(7,5)="0x38"
  num(7,6)="0x18"
  num(7,7)="0x1c"
  num(7,8)="0x1c"
  '数字8
  num(8,0)="0x7c"
  num(8,1)="0xfe"
  num(8,2)="0xee"
  num(8,3)="0x7c"
  num(8,4)="0x7c"
  num(8,5)="0xee"
  num(8,6)="0xee"
  num(8,7)="0xfe "
  num(8,8)="0x7c"
  '数字9
  num(9,0)="0x3c"
  num(9,1)="0x7c"
  num(9,2)="0xee"
  num(9,3)="0xee"
  num(9,4)="0xfe"
  num(9,5)="0xec"
  num(9,6)="0xe0"
  num(9,7)="0x7e"
  num(9,8)="0x3c"
  
  ‘-------------------------------------------------
  调用方法:
  
  把上面哪些东西放在一个页面里面,命名为Verify.asp
  
  然后这样:<img src="verify.asp">
  

上一个:C#实现的18位身份证格式验证算法
下一个:Visual Studio.Net 快捷键表

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,