ASP generation Verification Code Instance code

Source: Internet
Author: User

ASP tutorial to generate the code instance of verification code

Call Com_creatvalidcode ("Validcode")
Sub Com_creatvalidcode (PS tutorial N)
' Disable caching
Response.Expires =-1
Response.ExpiresAbsolute = Now ()-1
Response.CacheControl = "No-cache"
' Response.Expires =-9999
' Response.AddHeader ' pragma ', ' no-cache '
' Response.AddHeader ' Cache-ctrol ', ' No-cache '
Response.ContentType = "Image/bmp"
Randomize
Dim i, II, III
Const CODDS = 0 ' Odds of occurrence of miscellaneous points
Const CAMOUNT = 9 ' text quantity, 34 is number plus English
Const CCODE = "123456789ABCDEFGHIJKLMNPQRSTUVWXYZ"
' Const Ccode = ' 123456789abcdefghijklmnopqrstuvwxyz '
' Color data (character, background)
Dim Vcolordata (1)
' Vcolordata (0) = ChrB (255) & ChrB (0) & ChrB (0) ' Blue 0, Green 0, Red 0 (black)
' Vcolordata (1) = CHRB (211) & ChrB (255) & ChrB (255) ' Blue 250, green 236, red 211 (light blue)
Vcolordata (0) = ChrB (Wuyi) & ChrB (Wuyi) & ChrB (51) ' Blue 0, Green 0, Red 0 (black)
Vcolordata (1) = ChrB (255) & ChrB (255) & ChrB (255) ' Blue 250, green 236, red 211 (light blue)
' Randomly generated characters
Dim Vcode (4), vcodes
For i = 0 to 3
Vcode (i) = Int (RND * camount)
Vcodes = Vcodes & Mid (Ccode, Vcode (i) + 1, 1)
Next
' Character of the data
Dim Vnumberdata (33)
' 0 vnumberdata (0) = " 1110000111110111101111011110111101001011110100101111010010111101001011110111101111011110111110000111 "
Vnumberdata (0) = " 1111011111110001111111110111111111011111111101111111110111111111011111111101111111110111111100000111 "
Vnumberdata (1) = " 1110000111110111101111011110111111111011111111011111111011111111011111111011111111011110111100000011 "
Vnumberdata (2) = " 1110000111110111101111011110111111110111111100111111111101111111111011110111101111011110111110000111 "
Vnumberdata (3) = " 1111101111111110111111110011111110101111110110111111011011111100000011111110111111111011111111000011 "
Vnumberdata (4) = " 1100000011110111111111011111111101000111110011101111111110111111111011110111101111011110111110000111 "
Vnumberdata (5) = " 1111000111111011101111011111111101111111110100011111001110111101111011110111101111011110111110000111 "
Vnumberdata (6) = " 1100000011110111011111011101111111101111111110111111110111111111011111111101111111110111111111011111 "
Vnumberdata (7) = " 1110000111110111101111011110111101111011111000011111101101111101111011110111101111011110111110000111 "
Vnumberdata (8) = " 1110001111110111011111011110111101111011110111001111100010111111111011111111101111011101111110001111 "
Vnumberdata (9) = " 1111011111111101111111101011111110101111111010111111101011111100000111110111011111011101111000100011 "
Vnumberdata (10) = " 1000000111110111101111011110111101110111110000111111011101111101111011110111101111011110111000000111 "
Vnumberdata (11) = " 1110000011110111101110111110111011111111101111111110111111111011111111101111101111011101111110001111 "
Vnumberdata (12) = " 1000001111110111011111011110111101111011110111101111011110111101111011110111101111011101111000001111 "
Vnumberdata (13) = " 1000000111110111101111011011111101101111110000111111011011111101101111110111111111011110111000000111 "
Vnumberdata (14) = " 1000000111110111101111011011111101101111110000111111011011111101101111110111111111011111111000111111 "
Vnumberdata (15) = " 1110000111110111011110111101111011111111101111111110111111111011100011101111011111011101111110001111 "
Vnumberdata (16) = " 1000100011110111011111011101111101110111110000011111011101111101110111110111011111011101111000100011 "
Vnumberdata (17) = " 1100000111111101111111110111111111011111111101111111110111111111011111111101111111110111111100000111 "
Vnumberdata (18) = " 1110000011111110111111111011111111101111111110111111111011111111101111111110111110111011111000011111 "
Vnumberdata (19) = " 1000100011110111011111011011111101011111110001111111010111111101101111110110111111011101111000100011 "
Vnumberdata (20) = " 1000111111110111111111011111111101111111110111111111011111111101111111110111111111011110111000000011 "
Vnumberdata (21) = " 1000100011110010011111001001111100100111110101011111010101111101010111110101011111010101111001010011 "
Vnumberdata (22) = " 1000100011110011011111001101111101010111110101011111010101111101100111110110011111011001111000110111 "
' O vnumberdata (24) = ' 1110001111110111011110111110111011111011101111101110111110111011111011101111101111011101111110001111 "
Vnumberdata (23) = " 1000000111110111101111011110111101111011110000011111011111111101111111110111111111011111111000111111 "
Vnumberdata (24) = " 1110001111110111011110111110111011111011101111101110111110111011111011101001101111011001111110001011 "
Vnumberdata (25) = " 1000001111110111011111011101111101110111110000111111010111111101101111110110111111011101111000110011 "
Vnumberdata (26) = " 1110000011110111101111011110111101111111111001111111111001111111111011110111101111011110111100000111 "
Vnumberdata (27) = " 1000000011101101101111110111111111011111111101111111110111111111011111111101111111110111111110001111 "
Vnumberdata (28) = " 1000100011110111011111011101111101110111110111011111011101111101110111110111011111011101111110001111 "
Vnumberdata (29) = " 1000100011110111011111011101111101110111111010111111101011111110101111111010111111110111111111011111 "
Vnumberdata (30) = " 1001010011110101011111010101111101010111110101011111001001111110101111111010111111101011111110101111 "
Vnumberdata (31) = " 1000100011110111011111101011111110101111111101111111110111111110101111111010111111011101111000100011 "
Vnumberdata (32) = " 1000100011110111011111011101111110101111111010111111110111111111011111111101111111110111111110001111 "
Vnumberdata (33) = " 1100000011110111011111111101111111101111111110111111110111111111011111111011111111101110111100000011 "

     ' output image file header
     response.binarywrite ChrB ($) & ChrB (+) & CHRB (230) & ChrB (4) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) &_
     & nbsp;     ChrB (0) & ChrB (0) & ChrB (i) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (40 ) & ChrB (0) &_
           chrb (0) & ChrB (0) & CHRB (+) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (a) & ChrB (0) &_
     & nbsp;     ChrB (0) & ChrB (0) & ChrB (1) & ChrB (0)

' Output image information header
Response.BinaryWrite ChrB & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (176) & CHRB (4) &_
ChrB (0) & ChrB (0) & ChrB (a) & ChrB (one) & ChrB (0) & ChrB (0) & ChrB (a) & ChrB (one) &_
ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) &_
ChrB (0) & ChrB (0)

For i = 9 to 0 step-1 ' after all lines
For II = 0 to 3 ' after all words
For III = 1 to 10 ' after all pixels
' Output image data by line, word, pixel
If RND * 999 + 1 < Codds Then ' randomly generated miscellaneous points, the larger the number, the smaller the number
Response.BinaryWrite vcolordata (0)
Else
Response.BinaryWrite Vcolordata (Mid Vnumberdata (Vcode (ii)), I * + III, 1))
End If
Next
Next
Next
Session (PSN) = Vcodes ' Log into session
End Sub

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.