The xbm graph generated by ASP can be used as a verification code.

Source: Internet
Author: User
This program is mainly to generate a random number, and then convert the generated random number as the content of the xbm image, and finally display the image. the number to be obtained during verification is compared with the session ("validatecode"). If they are equal, the verification is passed (note that the two data types in comparison are consistent ).

How to display the generated image? </img>

For the format information of the xbm image, see here
Http://www.zdnet.com.cn/developer/tech/story/0,2000081602,39134972,00.htm

The xbm. ASP code is as follows:

Program code:
<! -- # Include file = "numcode. asp" -->
<%
'Enable Buffering
Response. Buffer = true
With response
. Expires =-1
. Addheader "Pragma", "No-Cache"
. Addheader "cache-ctrol", "No-Cache"
End

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
%>

The numcode. ASP code is as follows:

Program code:
<%
Dim A (10, 10)
A (0, 1) = "0x3c" 'number 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" 'Number 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" 'number 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" 'number 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" 'Number 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" 'number 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" 'Number 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" 'number 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" 'number 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" 'Number 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"
%>

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.