Another very good verification code is recommended.

Source: Internet
Author: User
The features of this verification code generation program are as follows:

1. Color;
2. BMP images have a color depth of 16 bits, and the generated images are smaller. (the four-digit long verification code is only several hundred bytes)
3. The length can be customized. (one to 25 digits can be fixed or changed to dynamic)
4. The background and noise depth can be customized;
For details, refer to the code
Note: The Code does not set the verification code session for the mobile network. If you want to use it, change the location to the line of Session ("num") in the Code and change it to the name you need. This verification code can also be used in any place where the verification code is needed. You do not need to go to the dynamic network forum.

The following is the code:

<%
Option explicit
Response. expires = 0
Response. addheader "Pragma", "No-Cache"
Response. addheader "cache-ctrol", "No-Cache"
Response. contenttype = "image/BMP"
Randomize Timer

Dim text_data (9), text_len, int_temp (), I, J, K, int_temp2

''' ***** Parameter configuration area *****

Text_len = 4'' verification code length (1-25 characters supported)

''**********************

Redim int_temp (text_len-1)

Text_data (0) = "00000000000001111000001100110000110111000011011100001100110000111011000011101100001100110000011110000000000000"
Text_data (1) = "00000000000000011000000011100000111110000000011000000001100000000110000000011000000001100000000110000000000000"
Text_data (2) = "00000000000001111000001100110000110011000000001100000001100000001100000001100000001100000000111111000000000000"
Text_data (3) = "00000000000001111000001100110000110011000000001100000011100000000011000011001100001100110000011110000000000000"
Text_data (4) = "00000000000001100000000110000000011011000001101100000110110000110011000011111110000000110000000011000000000000"
Text_data (5) = "00000000000011111100001100000000110000000011000000001111100000000011000000001100000001100000111100000000000000"
Text_data (6) = "00000000000000111000000011000000011000000011111000001100110000110011000011001100001100110000011110000000000000"
Text_data (7) = "00000000000011111100000000110000000110000000011000000011000000001100000001100000000110000000011000000000000000"
Text_data (8) = "00000000000001111000001100110000110011000011101100000111100000110111000011001100001100110000011110000000000000"
Text_data (9) = "00000000000001111000001100110000110011000011001100001100110000011111000000011000000011000000011100000000000000"

''The verification codes are randomly generated below
Session ("num") = ""
For I = 0 to text_len-1
Int_temp (I) = int (RND * 10)
Session ("num") = SESSION ("num") + mid ("0123456789", int_temp (I) +)
Next

''Output file header section
Int_temp2 = (text_len-1) \ 4*220 + (text_len-1)/4-(text_len-1) \ 4*4) * 44
Response. binarywrite chrb (& h42) & chrb (& h4d)
Response. binarywrite chrb (int_temp2 + 206)/256-(int_temp2 + 206) \ 256) * 256) & chrb (int_temp2 + 206) \ 256) ''special bit
Response. binarywrite chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (& h76) & chrb (0) & chrb (0) & chrb (0) & chrb (& H28) & chrb (0) & chrb (0) & chrb (0)
Response. binarywrite chrb (text_len * 10) ''special bit
Response. binarywrite chrb (0) & chrb (0) & chrb (0) & chrb (& Hb) & chrb (0) & chrb (0) & chrb (0) & chrb (& H1) & chrb (0) & chrb (& h4) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0)
Response. binarywrite chrb (int_temp2 + 88)/256-(int_temp2 + 88) \ 256) * 256) & chrb (int_temp2 + 88) \ 256) ''special bit

Response. binarywrite chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (16) & chrb (0) & chrb (0) & chrb (0) & chrb (16) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (0) & chrb (& h80) & chrb (0) & chrb (0) & chrb (& h80) & chrb (0) & chrb (0) & chrb (0) & chrb (& h80) & chrb (& h80) & chrb (0) & chrb (& h80) & chrb (0) & chrb (0) & chrb (0) & chrb (& h80) & chrb (0) & chrb (& h80) & chrb (0)
Response. binarywrite chrb (& h80) & chrb (& h80) & chrb (0) & chrb (0) & chrb (& h80) & chrb (& h80) & chrb (& h80) & chrb (0) & chrb (& hc0) & chrb (& hc0) & chrb (& hc0) & chrb (0) & chrb (0) & chrb (0) & chrb (& HFF) & chrb (0) & chrb (0) & chrb (& HFF) & chrb (0) & chrb (0) & chrb (0) & chrb (& HFF) & chrb (0) & chrb (& HFF) & chrb (0) & chrb (0) & chrb (0) & chrb (& HFF) & chrb (0) & chrb (& HFF) & chrb (0) & chrb (& HFF) & chrb (0) & chrb (0) & chrb (& HFF) & chrb (0)

''Output image data below
For I = 10 to 0 step-1
For J = 0 to text_len-1
For k = 1 to 9 Step 2
If mid (text_data (int_temp (j), I * 10 + k, 1) = "0" then int_temp2 = get_backcolor () * 16 else int_temp2 = get_forecolor () * 16
If mid (text_data (int_temp (j), I * 10 + k + 1, 1) = "0" then int_temp2 = int_temp2 + get_backcolor () else int_temp2 = int_temp2 + get_forecolor ()
Response. binarywrite chrb (int_temp2)
Next
Next
Int_temp2 = (text_len/4-text_len \ 4) * 4
Select case int_temp2
Case 1
Response. binarywrite chrb (0) & chrb (0) & chrb (0)
Case 2
Response. binarywrite chrb (0) & chrb (0)
Case 3
Response. binarywrite chrb (0)
End select
Next

''To get a background color
Function get_backcolor ()
If int (RND * 30) = 0 then ''Note: The RND * 30 determines the number of background colors. The larger the value, the less the background colors.
Get_backcolor = CINT (mid ("00021209", INT (RND * 4) * 2 + ))
Else
Get_backcolor = CINT (mid ("081515151515", INT (RND * 6) * 2 + ))
End if
End Function

''To get a foreground color
Function get_forecolor ()
Get_forecolor = CINT (mid ("00021209", INT (RND * 4) * 2 + ))
End Function
%>

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.