No component generates verification code-GIF format
Copy codeThe Code is as follows: <%
Option Explicit 'display Declaration
Class Com_GifCode_Class
'''''''''''''''''''''''''''''''''''''''' '''''
'Author: Layen support@ssaw.net 84815733 (QQ)
'Thanks: Laomi, Laomiao, NetRube
'2006-01-02
'''''''''''''''''''''''''''''''''''''''' '''''
Public Noisy, Count, Width, Height, Angle, Offset, Border
Private Graph (), Margin (3)
Private Sub Class_Initialize ()
Randomize
Noisy = 16' probability of occurrence of interference points
Count = 4' Character Count
Width = 80' Image Width
Height = 20' Image Height
Angle = 2' random Angle variation
Offset = 20' Offset random variation
Border = 1' Border size
End Sub
Public Function Create ()
Const ccharsets = "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, vIndex + 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,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,100, 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, 1, 30,100, 70,100, 80, 70,100, 30,100, 1, 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 vExtent: 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, vHeight, vDX, vDY, vDeltaT
Dim vAngle, vLength
VWidth = Int (Margin (1)-Margin (0 ))
VHeight = Int (Margin (3)-Margin (2 ))
'Start Coordinate
VStartX = Int (DotData (pIndex) (0)-1) * vWidth/100)
VStartY = Int (DotData (pIndex) (1)-1) * vHeight/100)
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
'Terminal Coordinate
VEndX = (DotData (pIndex) (2 * I)-1) * vWidth/100
VEndY = (DotData (pIndex) (2 x I + 1)-1) * vHeight/100
'Horizontal gap
VDX = vEndX-vStartX
'Vertical gap
VDY = vEndY-vStartY
'Skew Angle
If vDX = 0 Then
VAngle = Sgn (vDY) * 3.14/2
Else
VAngle = Atn (vDY/vDX)
End If
'Coordinate distance
If Sin (vAngle) = 0 Then
VLength = vDX
Else
VLength = vDY/Sin (vAngle)
End If
'Random rotation angular
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 * vDY/vDeltaT
Next
VStartX = vStartX + vDX
VStartY = vStartY + vDY
End If
Next
End Sub
Public Sub Output ()
Response. Expires =-9999
Response. AddHeader "pragma", "no-cache"
Response. AddHeader "cache-ctrol", "no-cache"
Response. ContentType = "image/gif"
'File type
Response. BinaryWrite ChrB (Asc ("G") & ChrB (Asc ("I") & ChrB (Asc ("F "))
'Version info
Response. BinaryWrite ChrB (Asc ("8") & ChrB (Asc ("9") & ChrB (Asc (""))
'Logical screen width
Response. BinaryWrite ChrB (Width Mod 256) & ChrB (Width \ 256) Mod 256)
'Logical 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 identifier
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 height
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
%>
No component generates verification code-BMP formatCopy codeThe Code is as follows: Call Com_CreatValidCode ("ValidCode ")
Sub Com_CreatValidCode (pSN)
'Author: Layen
'Qq: 84815733
'E-mail: support@ssaw.net
'Prohibit caching
Response. Expires =-9999
Response. AddHeader "Pragma", "no-cache"
Response. AddHeader "cache-ctrol", "no-cache"
Response. ContentType = "Image/BMP"
Randomize
Dim I, ii, iii
Const cOdds = 8' probability of occurrence of miscellaneous
Const cAmount = 36' text count
Const cCode = "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
'Color data (character, background)
Dim vColorData (1)
VColorData (0) = ChrB (0) & ChrB (0) & ChrB (0) 'Blue 0, green 0, red 0 (black)
VColorData (1) = ChrB (250) & ChrB (236) & ChrB (211) 'Blue 250, green 236, red 211 (light blue)
'Randomly generated characters
Dim vCode (4), vCodes
For I = 0 To 3
VCode (I) = Int (Rnd * cAmount)
VCodes = vCodes & Mid (cCode, vCode (I) + 1, 1)
Next
Session (pSN) = vCodes 'record the Session
'Character data
Dim vNumberData (35)
VNumberData (0) = "1110000111110111101111011110111101001011110100101111"
010010111101001011110111101111011110111110000111"
VNumberData (1) = "1111011111110001111111110111111111011111111101111111"
110111111111011111111101111111110111111100000111"
VNumberData (2) = "1110000111110111101111011110111111111011111111011111"
111011111111011111111011111111011110111100000011"
VNumberData (3) = "1110000111110111101111011110111111110111111100111111"
111101111111111011110111101111011110111110000111"
VNumberData (4) = "1111101111111110111111110011111110101111110110111111"
011011111100000011111110111111111011111111000011"
VNumberData (5) = "1100000011110111111111011111111101000111110011101111"
111110111111111011110111101111011110111110000111"
VNumberData (6) = "1111000111111011101111011111111101111111110100011111"
001110111101111011110111101111011110111110000111"
VNumberData (7) = "1100000011110111011111011101111111101111111110111111"
110111111111011111111101111111110111111111011111"
VNumberData (8) = "1110000111110111101111011110111101111011111000011111"
101101111101111011110111101111011110111110000111"
VNumberData (9) = "1110001111110111011111011110111101111011110111001111"
100010111111111011111111101111011101111110001111"
VNumberData (10) = "1111011111111101111111101011111110101111111010111111"
101011111100000111110111011111011101111000100011"
VNumberData (11) = "1000000111110111101111011110111101110111110000111111"
011101111101111011110111101111011110111000000111"
VNumberData (12) = "1110000011110111101110111110111011111111101111111110"
111111111011111111101111101111011101111110001111"
VNumberData (13) = "10000011111101110111110111101111011110111101111011110"
11110111101111011110111101111011101111000001111"
VNumberData (14) = "10000001111101111011110110111111011011111100001111110"
11011111101101111110111111111011110111000000111"
VNumberData (15) = "10000001111101111011110110111111011011111100001111110"
11011111101101111110111111111011111111000111111"
VNumberData (16) = "11100001111101110111101111011110111111111011111111101"
11111111011100011101111011111011101111110001111"
VNumberData (17) = "10001000111101110111110111011111011101111100000111110"
11101111101110111110111011111011101111000100011"
VNumberData (18) = "11000001111111011111111101111111110111111111011111111"
10111111111011111111101111111110111111100000111"
VNumberData (19) = "11100000111111101111111110111111111011111111101111111"
11011111111101111111110111110111011111000011111"
VNumberData (20) = "10001000111101110111110110111111010111111100011111110"
10111111101101111110110111111011101111000100011"
VNumberData (21) = "10001111111101111111110111111111011111111101111111110"
11111111101111111110111111111011110111000000011"
VNumberData (22) = "10001000111100100111110010011111001001111101010111110"
10101111101010111110101011111010101111001010011"
VNumberData (23) = "10001000111100110111110011011111010101111101010111110"
10101111101100111110110011111011001111000110111"
VNumberData (24) = "11100011111101110111101111101110111110111011111011101"
11110111011111011101111101111011101111110001111"
VNumberData (25) = "10000001111101111011110111101111011110111100000111110"
11111111101111111110111111111011111111000111111"
VNumberData (26) = "11100011111101110111101111101110111110111011111011101"
11110111011111011101001101111011001111110001011"
VNumberData (27) = "10000011111101110111110111011111011101111100001111110"
10111111101101111110110111111011101111000110011"
VNumberData (28) = "11100000111101111011110111101111011111111110011111111"
11001111111111011110111101111011110111100000111"
VNumberData (29) = "10000000111011011011111101111111110111111111011111111"
10111111111011111111101111111110111111110001111"
VNumberData (30) = "10001000111101110111110111011111011101111101110111110"
11101111101110111110111011111011101111110001111"
VNumberData (31) = "10001000111101110111110111011111011101111110101111111"
01011111110101111111010111111110111111111011111"
VNumberData (32) = "10010100111101010111110101011111010101111101010111110"
01001111110101111111010111111101011111110101111"
VNumberData (33) = "10001000111101110111111010111111101011111111011111111"
10111111110101111111010111111011101111000100011"
VNumberData (34) = "10001000111101110111110111011111101011111110101111111"
10111111111011111111101111111110111111110001111"
VNumberData (35) = "11000000111101110111111111011111111011111111101111111"
10111111111011111111011111111101110111100000011"
'Output image file headers
Response. binaryWrite ChrB (66) & ChrB (77) & ChrB (230) & ChrB (4) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) &_
ChrB (0) & ChrB (0) & ChrB (54) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (40) & ChrB (0) &_
ChrB (0) & ChrB (0) & ChrB (40) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (10) & ChrB (0) &_
ChrB (0) & ChrB (0) & ChrB (1) & ChrB (0)
'Output Image Information Headers
Response. binaryWrite ChrB (24) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & chrb( 176) & ChrB (4) &_
ChrB (0) & ChrB (0) & ChrB (18) & ChrB (11) & ChrB (0) & ChrB (0) & ChrB (18) & ChrB (11) &_
ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) & ChrB (0) &_
ChrB (0) & ChrB (0)
For I = 9 To 0 Step-1 'goes through all rows
For ii = 0 To 3' goes through all words
For iii = 1 To 10' goes through all pixels
'Output image data row by row, word by word, and pixel by Pixel
If Rnd * 99 + 1 <cOdds then' random generation of miscellaneous
Response. BinaryWrite vColorData (0)
Else
Response. BinaryWrite vColorData (Mid (vNumberData (vCode (ii), I * 10 + iii, 1 ))
End If
Next
Next
Next
End Sub