1.在许多论坛的登录页面上,都有一个附加码,这样做的目的是防止有人利用破解程序,暴力破解里面的密码
2.生成附加码的代码:
<%
Response.Buffer=false
NumCode
Function NumCode()
Response.Expires=-1
Response.AddHeader "Progma","no-cache"
Response.AddHeader "cache-control","no-cache"
dim rndnum,i,j
dim Ados,Ados1
Do While len(rndnum)<4
num1=Cstr(Chr((57-48)*rnd +48))
rndnum=rndnum & num1
loop
Session("adminid")=rndnum
dim zimag(4),nstr
nstr=cstr(rndnum)
for i=0 to 3
zimag(i)=cint(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
Ados1.LoadFromFile(Server.mapPath("images/body.Fix"))
Ados1.Write Ados.read(1280)
for i=0 to 3
Ados.Position=(9-zimage(i))*320
Ados1.Position=i*320
Ados1.Write Ados.read(320)
next
Ados.LoadFromFile(Server.mapPath("images/head.fix"))
Pos=lenb(Ados.read())
Ados.Position=pos
for i=0 to 9 step 1
for j=0 to 3
Ados.Position=i*32+j*320
Ados1.Postion=pos+30*j+i*120
Ados.write.ados1.read(30)
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
%>
3.调用方法
<% response.write "<img src=code.asp>" %>