asp中生成xbm格式的验证码

<%
'**********************************************
'* NAME:checkcode.asp                                                                  *                                                       
'*  USE:生成xbm格式的验证码                                                       *

**********************************************
on error resume next
dim i
dim countdata
countdata="1234567890"
dim rou,chkcode,chklen
chkcode=""
chklen = 4
randomize
for i=1 to 4
   rou = int(rnd*10)
   chkcode = chkcode + cstr(rou)
next

dim strDigits
strDigits = Array(_
         "0","0x3c","0x66","0x66","0x66","0x66","0x66","0x66","0x66","0x66","0x3c",_
         "1","0x30","0x38","0x30","0x30","0x30","0x30","0x30","0x30","0x30","0x30",_
         "2","0x3c","0x66","0x60","0x60","0x30","0x18","0x0c","0x06","0x06","0x7e",_
         "3","0x3c","0x66","0x60","0x60","0x38","0x60","0x60","0x60","0x66","0x3c",_
         "4","0x30","0x30","0x38","0x38","0x34","0x34","0x32","0x7e","0x30","0x78",_
         "5","0x7e","0x06","0x06","0x06","0x3e","0x60","0x60","0x60","0x66","0x3c",_
         "6","0x38","0x0c","0x06","0x06","0x3e","0x66","0x66","0x66","0x66","0x3c",_
         "7","0x7e","0x66","0x60","0x60","0x30","0x30","0x18","0x18","0x0c","0x0c",_
         "8","0x3c","0x66","0x66","0x66","0x3c","0x66","0x66","0x66","0x66","0x3c",_
         "9","0x3c","0x66","0x66","0x66","0x66","0x7c","0x60","0x60","0x30","0x1c")

dim iCharWidth,iCharHeight,theBit,theNum,iRow,k,theOffset
dim imageStr
imageStr = ""

iCharWidth = 8
iCharHeight= 10*1
Response.ContentType ="image/x-xbitmap"
Response.Expires =0
Response.Write "#define counter_width "&iCharWidth*chklen&chr(13) & chr(10)
Response.Write "#define counter_height "&iCharHeight&chr(13) & chr(10)
Response.Write "static unsigned char counter_bits[]={"
for iRow=0 to iCharHeight-1
   for i=1 to chklen
      theBit=mid(chkcode,i,1)
      k=0
      do while k<ubound(strDigits)
          if strDigits(k) = theBit then exit do
          k=k+iCharHeight+1
      loop
      if k>=ubound(strDigits) then k=0
      theOffset = k + 1
      imageStr = imageStr + (strDigits(theOffset+iRow))&","
   next
next
imageStr = left(imageStr,(len(imageStr)-1))
Response.Write imageStr

Response.Write "};"
session("chkCode") = chkcode
%> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值