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
%>