Asp verification code generation program

Source: Internet
Author: User

// Original: www.111cn.net

Note: For reprint, please indicate www.111cn.net

//

The following describes the methods for generating and verifying asp Programs.

<%
Option Explicit
Response. buffer = true
NumCode
Dim znum
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 ("ver") = znum' write the verification code to the SESSION
Dim zimg (4), NStr
NStr = cstr (zNum)
For I = 0 to 3
Zimg (I) = cint (mid (NStr, I + 1, 1 ))
Next
Dim Pos
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
Ados1.Open
Ados. LoadFromFile (Server. mappath ("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)
Next
Ados. LoadFromFile (Server. mappath ("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 ados1.read (30)
Next
Next
Response. ContentType = "image/BMP"
Ados. Position = 0
Response. BinaryWrite Ados. read ()
Ados. Close: set Ados = nothing
Ados1.Close: set Ados1 = nothing
End Function
%>

On the page to be called, set aaa.htm to ,

During verification, you must determine whether the user input is equal to the session ("ver.

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.