Author: loster (OICQ: 181306). If it is reprinted, please do not remove this line. Thank you.
Currently, verification codes are required for login on many websites. Verification codes are generally displayed in the form of images. This improves login security and prevents brute force password cracking. Why use the image display verification code? Imagine that if you only generate a text verification code, the attacker can use a technology similar to a thief to read your page, analyze the verification code, and finally perform brute force guesses. In this way, the Verification Code has no practical significance. Let's talk about how to display the image verification code in ASP.
To display the image verification code in ASP, you must first use the following three files:
Getcode. asp (used to generate image verification code)
Head. Fix (image header)
Body. Fix (image subject)
You may ask, where can I get these files? Don't worry. These files are available in dvbbs7.0. I also learned how to use the image verification code after studying the verification code in dvbbs7.0.
First, let's take a look at the getcode. asp file, which contains several lines like this:
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 "))
Have you seen the body. Fix and head. Fix? This refers to their relative location with getcode. asp. If the three files are in the same directory, you can follow the above statements. If not, you need to write out the relative location between them and getcode. asp. For example, if getcode. asp is in the root directory and body. Fix & head. Fix is in the test folder under the root directoryCodeYou need to change it:
Ados. loadfromfile (server. mappath ("test/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 ("test/head. Fix "))
In this way, the image can be displayed normally.
How to call it?
It is very simple, just like this:
You can.
Each time getcode. asp is called, a session is automatically generated, which stores the same four digits as the ones displayed on the verification image. You only need to compare the Received verification code with this session, and then determine whether the verification code is entered correctly. Of course, it is most like this:
If CSTR (TRIM (variable name received) = CSTR (Session ("getcode") then
Response. Write ("OK! ")
Else
Response. Write ("No! ")
End if
So far, it's finished. I hope you will be inspired by this article. Of course, my skills are limited, and errors will inevitably occur in this article. please correct me.
Someone may ask if the image can be modified. The answer is yes. There is something online.ArticleYou can check.
Appendix: http://www.loster.net/aspfile/getcode.rar getcode. asp, head. Fix, body. Fix file compressed package