Making method of ASP color check code

Source: Internet
Author: User
Tags array header numeric modify

The main thing to read these code is to understand the objects that manipulate binary data in ASP adodb.stream! This procedure is mainly used is adodb.stream, if you have this basis, you can further add more features such as adding miscellaneous points, gradient background, the number of dislocation, strokes short points, improve the recognition of the impossible by OCR. There is no good identification engine, yesterday downloaded a claim to recognize the image verification code 90%, the 4321 recognized as 89910, so the image code is still relatively safe.

On the Internet to see the method of violent cracking, if I use the image add-on code + prohibit the external submission + 10 times password Error seal account number + 50 times password error ip+10 seconds of the anti-refresh interval registration page, landing page Plus + prohibit external submissions, so that the violent cracking should not be done.

ASP File: code.asp

Data file: Body. Fix, Head.fix

Demo: This site PHP has no demo

Usage:

Modify the code a little bit, give a version that you can modify the number: Click to download , use the image software to open body.bmp directly edit the font and color you need!

Code.asp file:

response.buffer = True
Numcode
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
generates a random four-digit number:
Znum = CInt (8999*rnd+1000)
passes to session
session ("GetCode") = Znum
The For loop is an array of random numbers placed in a subscript 3 that is easy to provide to the subsequent array transforms
Dim zimg (3), Nstr
Nstr=cstr (znum)
for i=0 to 3
zimg (i) =cint ( nstr,i+1,1)
Next
Dim Pos

' defines two ADODB. Stream binary object for image data manipulation:

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
' Load 0~9 digital data 10x100, GBR array data, each 320 byte, 10 digits 3200byte
' bgr a point, 10x10 a dot a number, a point three bytes (binary 8 bits, 16 into 00~ff)
' Row 10 dots 30 byte + Line end tag 00 2 bytes 32 bytes, so a 10x100 width is less than the length of the image each number 10x10 is 320 bytes
' grew to wide then no line end tag 0000, directly 300 bytes
These are BMP 24bit data details.
' As for the head, also very simple, contains the long width, the image begins to mark and so on ~ ~ Only 54 bytes, far no jpg what the complex

ADOS.LOADFRomfile (Server.MapPath) ("body." Fix "))
Ados1.write ados.read (1280)
' first for loop, extract the corresponding four digits from the 10X100 digital array in the generated random numeric order, but the vertical numeric array
for i=0 to 3
ados.position= (9-zimg (i)) *320
ados1.position=i*320
ados1.write ados.read ()
Next
' to empty the data that has been used for ADOs, The header file
Ados.loadfromfile (Server.MapPath ("Head.fix"))
, which replaces the new image Header 54 bytes, is transferred to the Pos=lenb (Ados.read ())
ados.position= POS ' Specifies POS location, you can then offset the 54-byte position to add the graphic data, the second for loop, the number of array transformation, from the vertical block to the horizontal number of blocks, the method is 320 bytes to extract 4 times 30 bytes to write the ADOs object, and then extract the second row of image data, 30 bytes is due to a BMP wide long without 00 00 Line end Tags
for i=0 to 9 Step 1
for j=0 to 3
ados1.position=i*32+j*320
ados.position=pos+30 *j+i*120
Ados.write ados1.read
Next
Next
ados.position=0
Response. BinaryWrite ' sends image data directly to the client
Response.ContentType = ' image/bmp '
Response.BinaryWrite ados.read ()
Ados.close: Set ados=nothing
Ados1.Close:set ados1=nothing
End Function

Apply to the page:

Submit page:

------Login.asp-----

<form action= "chklogin.asp" method= "POST" >
Account Number: <input name= "Acco" type= "text" ><br>
Password: <input name= "Pass" type= "text" ><br>
Check code: <input name= "GetCode" type= "text" >
</form>


Processing page:

--------chklogin.asp--------

<%
Dim Getcode,valicode
Getcode=int (Request ("GetCode")
Valicode=int (Session ("GetCode")
If Getcode<>valicode Then
Response.Write ("Validation code input error, please re-enter")
Response.End
End If
%>







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.