ASP implements a GIF format verification code without component, friends who need ASP verification code can refer to it.
<%
Option EXPLICIT 'Display Statement
Class com_gifcode_class
Public noisy, count, width, height, angle, offset, border
Private graph (), margin (3)
Private sub class_initialize ()
Randomize
Noisy = 16 'The probability of the interference point appears
Count = 4 'character quantity
Width = 80 'picture width
Height = 20 'picture height
Angle = 2 'Announced random change
Offset = 20 'Random changes to offset
Border = 1 'Frame size
End sub
Public function create ()
Const ccharset = 123456789
Dim i, x, y
DIM VVALIDCODE: VVALIDCode =
Dim vindex
Redim Graph (Width-1, Height-1)
For i = 0 to count -1
vindex = int (RND * Len (CCHARSET))
vvalidCode = VVALIDCode + MID (CCHARSET, VIDEX + 1, 1)
Setdraw vindex, i
Next
Create = VVALIDCODE
End function
Sub setdot (px, py)
If px * (Width-PX-1)> = 0 and Py * (Height-PY-1)> = 0 THEN
Graph (px, py) = 1
End if
End sub
Public sub setdraw (pindex, pnumber)
'Character data
Dim dotdata (8)
Dotdata (0) = Array (30, 15, 50, 1, 50, 100)
Dotdata (1) = Array (1, 34, 30, 1, 71, 1, 100, 34, 1, 100, 93, 100, 86)
Dotdata (2) = Array (1, 1, 100, 1, 42, 42, 100, 70, 50, 100, 1, 70)
Dotdata (3) = Array (100, 73, 6, 73, 75, 6, 75, 100)
Dotdata (4) = Array (100, 1, 1, 1, 1, 50, 50, 35, 55, 100, 80, 50, 100, 1, 95)
DotData(5) = Array(100, 20, 70, 1, 20, 1, 1, 30, 1, 80, 30, 100, 70, 100, 100, 80, 100, 60, 70, 50, 30, 50 , 1, 60)
Dotdata (6) = Array (6, 26, 6, 6, 100, 6, 53, 100)
Dotdata (7) = ARRAY (100, 30, 100, 20, 70, 1, 30, 1, 1, 20, 30, 70, 80, 70, 100, 30, 100, 80, 80 , 1, 70, 100, 30)
DotData(8) = Array(1, 80, 30, 100, 80, 100, 100, 70, 100, 20, 70, 1, 30, 1, 1, 20, 1, 40, 30, 50, 70, 50 , 100, 40)
Dim vertent: vextent = width / count
Margin (0) = Border + VEXTENT * (RND * Offset) / 100 + Margin (1)
Margin (1) = VEXTENT * (PNUMBER + 1) -Border -VEXTENT * (RND * Offset) / 100
Margin (2) = Border + Height * (RND * Offset) / 100
Margin (3) = Height -Border -Height * (RND * Offset) / 100
DIM VSTARTX, VENDX, VSTARTY, VENDY
Dim vwidth, vdx, vdx, vdy, VDeltat
Dim Vangle, VLENGTH
vwidth = int (margin (1) -Margin (0))
vheight = int (margin (3) -Margin (2))
'Starting coordinates
vstartx = int ((dotdata (pindex) (0) -1) * vwidth / 100)
vstarty = int
Dim i, j
For i = 1 to ubound (dotdata (pindex), 1)/2
If dotdata (pindex) (2*i-2) <> 0 and dotdata (pindex) (2*i) <> 0 then
'End point coordinates
vendx = (dotdata (pindex) (2 * i) -1) * vwidth / 100
VENDY = (dotdata (pindex) (2 * i+1) -1) * vheight / 100
'Horizontal gap
vdx = vendx -vstartx
'Vertical gap
vdy = vendy -vstarty
'Tilt angle
If vdx = 0 THEN
vangle = sgn (VDY) * 3.14/2
Else
vangle = atn (VDY / VDX)
End if
'Two coordinate distance
If sin (vangle) = 0 then
vlength = vdx
Else
vlength = vdy / sin (vangle)
End if
'Random rotation angle
Vangle = Vangle + (RND -0.5) * 2 * Angle * 3.14 * 2 /100
vdx = int (cos (vangle) * vlength)
vdy = int (sin (vangle) * vlength)
If ABS (VDX)> ABS (VDY) then VDeltat = ABS (VDX) Else VDeltat = ABS (VDY)
For j = 1 to vdeltat
Setdot Margin (0) + VSTARTX + J * VDX / VDeltat, Margin (2) + VSTarty + J * VDELTATAT
Next
vstartx = VSTARTX + VDX
vstarty = vstarty + vdy
End if
Next
End sub
Public sub output ()
Response.expires = -9999
Response.addheader Pragma, No-Cache
Response.adheader cache-clm, no-cache
Response.contenttype = Image/GIF
'File type
Response.binarywrite chrb (ASC (G)) & chrb (ASC (I)) & chrb (ASC (F))
'Version information
Response.binarywrite chrb (ASC (8)) & chrb (ASC (9)) & chrb (ASC (A))
'Logic screen width
Response.binarywrite Chrb (Width Mod 256) & chrb ((Width / 256) MOD 256)
'Logic screen height
Response.binarywrite chrb (Height Mod 256) & chrb (Height / 256 MOD 256)
Response.binarywrite chrb (128) & chrb (0) & chrb (0)
'Global color list
Response.binarywrite chrb (255) & chrb (255) & chrb (255)
Response.binarywrite chrb (0) & chrb (85) & chrb (255)
'Image identification
Response.binarywrite chrb (asc (,,))
Response.binarywrite chrb (0) & chrb (0) & chrb (0) & chrb (0)
'Image width
Response.binarywrite Chrb (Width Mod 256) & chrb ((Width / 256) MOD 256)
'Image high
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))
Else
If x * (x-width) = 0 or y * (y-height) = 0 then
Response.binarywrite chrb (graph (x, y))
Else
If 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
End if
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
Set mcode = new com_gifcode_class
Session (getcode) = mcode.create ()
mcode.output ()
Set mcode = nothing
%>