Xbm| Verification Code This program is mainly a random number of gentlemen, and then according to the generated random number after transformation as the content of the XBM picture, the final display of this picture. The number to get the input and the session ("Validatecode") are compared when validating, and if the equality is verified (and the type of the two data being compared is consistent).
How do i show the generated picture? </img>
About the format information of the XBM graph, look here
Http://www.zdnet.com.cn/developer/tech/story/0,2000081602,39134972,00.htm
Xbm.asp's code is as follows
Program code:
<!--#include file= "numcode.asp"-->
<%
' Open buffer
Response.Buffer = True
With Response
. Expires =-1
. AddHeader "Pragma", "No-cache"
. AddHeader "Cache-ctrol", "No-cache"
End With
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 & 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 code for numcode.asp 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
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.