ASP Generate picture Verification code

Source: Internet
Author: User

The following code is an ASP generated image verification code program Oh, about the validation code to write the program most will know Oh, let's look at this picture verification code generation way bar.

<%
Option Explicit
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
 znum = CInt (8999*rnd+1000)
 session ( "GetCode") = Znum
 dim zimg (4), Nstr
  nstr=cstr (znum)
  for i=0 to 3
   zimg (i) =c Int (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 (1280)
  for i=0 to 3
   ados.position= (9-zimg (i)) *320
   ados1.position=i*320
  Ados1.write ados.read
  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
 &nbs p;  ados1.position=i*32+j*320
    ados.position=pos+30*j+i*120
    Ados.write ados1.read
   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
%>

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.