Production and use of the Verification Code (ASP)

Source: Internet
Author: User

The following is the function file for obtaining the verification code. Save the file as getcode. asp.

Option explicit
Response. Buffer = true
Function numcode ()
Response. expires =-1
Response. addheader "Pragma", "No-Cache"
Response. addheader "cache-ctrol", "No-Cache"
Dim znum, I, j
Dim Ados, ados1
Randomize Timer
Znum = CINT (8999 * RND + 1000)
Session ("getcode") = znum
Dim zimg (4), NSTR
NSTR = CSTR (znum)
For I = 0 to 3
Zimg (I) = CINT (mid (NSTR, I + 1, 1 ))
Set Ados = server. Createobject ("ADODB. Stream ")
Ados. mode = 3
Ados. type = 1
Ados. Open
Set ados1 = server. Createobject ("ADODB. Stream ")
Ados1.mode = 3
Ados1.type = 1
Ados. loadfromfile (server. mappath ("images/body. Fix "))
Ados1.write Ados. Read (1, 1280)
For I = 0 to 3
Ados. Position = (9-zimg (I) * 320
Ados1.position = I * 320
Ados1.write Ados. Read (1, 320)
Ados. loadfromfile (server. mappath ("images/head. Fix "))
Pos = lenb (Ados. Read ())
Ados. Position = POS
For I = 0 to 9 Step 1
For J = 0 to 3
Ados1.position = I x 32 + J x 320
Ados. Position = POS + 30 * j + I * 120
Ados. Write (30)
Response. contenttype = "image/BMP"
Ados. Position = 0
Response. binarywrite Ados. Read ()
Ados. Close: Set Ados = nothing
Ados1.close: Set ados1 = nothing
End Function

Body. Fix and head. Fix are digital image files.

During verification, you can use SESSION ("getcode") to compare the content in the input box.

If the reader needs two files, body. Fix and head. Fix, you can leave the E-MAIL and I will send it to you.

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: 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.