Generate XBM digital pictures with ASP (can be used to generate verification code)

Source: Internet
Author: User
Tags define array
Xbm| Verification Code

The XBM picture is a plain text file that can be derived from dynamic generation using ASP. It can be used to use the site login authentication code;
We use Notepad to open the file for analysis:
Its file structure is:
#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}
The file name extension is:. XBM

#define COUNTER_WIDTH 48 ' here defines the width of the picture, typically a multiple of 8
#define Counter_height 9 ' here defines the height of the picture, which is arbitrary.
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} ' here is the hexadecimal code of the picture used to display the content

As static unsigned char the English meaning is stationary, unsigned, and charred. It can only be used to show both black and white colors. The 1 in binary will be shown in black and 0 in white.

The following is a binary array of 0~9 digits in which the picture style is only tried for this example. If you need a different 0~9 number style, create it yourself.

' Here declares an array of 0~9 drawings

Dim num (9,8)
' number 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"
' number 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 "
' number 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 '
' number 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"
' number 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"
' number 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"
' number 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"
' number 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"
' number 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 "
' number 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 "


To implement this code, save the above array of digits (red) as funnum.asp
The file section below, save separately as an ASP page
<%
Response. Buffer=true
Response. Expiresabsolute=now ()-1
response.expires=0
Response. Cachecontrol= "No-cache"
%>
<!--#include file= "funnum.asp"
<!--funnum.asp is the number of arrays in the tutorial//--
<%
Const countheight=9 ' The height of the picture
Const COUNTLENGTH=6 ' The number of digits in the picture
Const NUMBINBIT=8 ' This is the number of bits in the numeric array, It seems like you can only use the eight-bit below 11111111
Const countwidth=48 ' countlength*numbinbit to get
Const imgtype= ' image/x-xbitmap '
Dim Countbody ' picture information
Dim tmpcountbody ' for storing the resulting picture data
tmpcountbody= "
countbody= #define JS_COUNTER_WIDTH" & Countwidth & vbCrLf
Countbody=countbody & "#define Js_counter_height" & Countheight & VbCrLf
Countbody=countbody & "Static unsigned char js_counter_bits[]={" & vbCrLf
Dim numid ' number to generate picture
Dim Numarray () ' divides the obtained numid into a single dimension array
numid= ' 369245 ' write a function to generate a number
If Len (numid) <countlength then
for I=1 to Countlength-len (numid)
NuMid= "0" & Numid
Next
End If
ReDim Numarray (Len (numid)-1) ' Defines an integer value for the array when you redefine the array size, use the expression
for i=0 to UBound (numarray,1)
Numarray (i) =mid (numid,i+1,1)
Next
for i=0 to CountHeight-1
for j=0 to Countlength-1
Tmpcountbody=tmpcountbody & Num (Numarray (j), I) & ","
Next
Next
Tmpcountbody=left (tmpcountbody , Len (tmpcountbody)-1)
Countbody=countbody & Tmpcountbody & "}"
Response.contenttype=imgtype
Response.Write Countbody
%>







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.