Method of using Picture Verification code in ASP

Source: Internet
Author: User
Author: loster (oicq:181306) if reproduced, please do not remove this trip, thank you.
Now many Web sites need to enter the login verification code, the verification code is generally in the form of pictures displayed. In this way, can improve the security of landing, to prevent violent guessing password. Why do I use a picture to display the verification code? Just imagine, if only generate the text of the verification code, crack people can use the technology similar to thieves, first of all you read this page, and then analyze the verification code, the final violent guess solution. In this case, the verification code has no practical significance. Less nonsense, below I began to say how to implement the ASP display picture verification code.
The following three files are required to implement the image verification code shown in asp:
Getcode.asp (for generating Picture verification code)
Head.fix (picture head)
Body.fix (picture body)
You might ask, where can I get these files? Don't worry, these files are in the dvbbs7.0. I also studied the dvbbs7.0 inside the verification code before learning how to use the image verification code.
First look at the getcode.asp file, there are a few lines is this:
Ados.loadfromfile (Server.MapPath) ("body." Fix "))
Ados1.write Ados.read (1280)
For I=0 to 3
ados.position= (9-zimg (i)) *320
ados1.position=i*320
Ados1.write Ados.read (320)
Next
Ados.loadfromfile (Server.MapPath ("Head.fix"))
Have you seen Body.fix and Head.fix? This refers to their relative position with the getcode.asp. If they have three files in a directory, just follow the above. If not, you need to write the relative positions between them and getcode.asp. For example, if getcode.asp is in the root directory and Body.fix&head.fix under the root directory under the test folder, then the code above should read:
Ados.loadfromfile (Server.MapPath ("Test/body"). Fix "))
Ados1.write Ados.read (1280)
For I=0 to 3
ados.position= (9-zimg (i)) *320
ados1.position=i*320
Ados1.write Ados.read (320)
Next
Ados.loadfromfile (Server.MapPath ("Test/head.fix"))
In this way, you can ensure that the picture appears normal.
How do I call it?
It's simple, it just needs to be:

Can.
Whenever getcode.asp is invoked, a session is automatically generated, which stores and verifies the same four-digit number displayed on the picture. You only need to compare the received verification code with this session and then determine if the verification code is typed correctly. Of course, it's better like this:
If Cstr (Trim (received variable name)) =cstr (Session ("GetCode")) Then
Response.Write ("ok!")
Else
Response.Write ("no!")
End If
Oh, so far,

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.