在Z-BLOG可用的新版ASP的GIF验证码[V70404]

2019-01-13 19:34:00丽君

Public Sub Output()
 Response.Expires = -9999
 Response.AddHeader "pragma", "no-cache"
 Response.AddHeader "cache-ctrol", "no-cache"
 Response.ContentType = "image/gif"
 Response.BinaryWrite ChrB(Asc("G")) & ChrB(Asc("I")) & ChrB(Asc("F"))
 Response.BinaryWrite ChrB(Asc("8")) & ChrB(Asc("9")) & ChrB(Asc("a"))
 Response.BinaryWrite ChrB(Width Mod 256) & ChrB((Width  256) Mod 256)
 Response.BinaryWrite ChrB(Height Mod 256) & ChrB((Height  256) Mod 256)
 Response.BinaryWrite ChrB(128) & ChrB(0) & ChrB(0)
 Response.BinaryWrite ChrB(250) & ChrB(250) & ChrB(250)
 Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0)
 Response.BinaryWrite ChrB(Asc(","))
 Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0)
 Response.BinaryWrite ChrB(Width Mod 256) & ChrB((Width  256) Mod 256)
 Response.BinaryWrite ChrB(Height Mod 256) & ChrB((Height  256) Mod 256)
 Response.BinaryWrite ChrB(0) & ChrB(7) & ChrB(255)

 Dim x, y, i : i = 0
 For y = 0 To Height - 1
  For x = 0 To Width - 1
   If Rnd < Noisy / 100 Then
    Response.BinaryWrite ChrB(1-Graph(x, y))
   ElseIf x * (x-Width) = 0 Or y * (y-Height) = 0 Then
    Response.BinaryWrite ChrB(Graph(x, y))
   ElseIf Graph(x-1, y) = 1 Or Graph(x, y) Or Graph(x, y-1) = 1 Then
    Response.BinaryWrite ChrB(1)
   Else
    Response.BinaryWrite ChrB(0)
   End If

   If (y * Width + x + 1) Mod 126 = 0 Then
    Response.BinaryWrite ChrB(128)
    i = i + 1
   End If
   If (y * Width + x + i + 1) Mod 255 = 0 Then
    If (Width*Height - y * Width - x - 1) > 255 Then
     Response.BinaryWrite ChrB(255)
    Else
     Response.BinaryWrite ChrB(Width * Height Mod 255)
    End If
   End If
  Next
 Next
 Response.BinaryWrite ChrB(128) & ChrB(0) & ChrB(129) & ChrB(0) & ChrB(59)
End Sub
End Class
Dim mCode
Dim code
Set mCode = New Com_GifCode_Class
mCode.Create(GetVerifyNumber)
mCode.Output()
Set mCode = Nothing
%>