/pub/verifycode
功能特性:
自動生成GIF格式的圖片,可以設置為GIF87a或GIF89a格式。
您可以自定義圖片的背景色和前景色。
驗證碼文本的隨機移位
自動生成幹擾噪聲點,噪聲點數量可自定義。
文本和噪聲可以指定為單色或彩色。
圖片會隨著文件的長度自動變化。
目前僅支持數字文本。
verifycode.asp
& lt% @ LANGUAGE = " VBSCRIPT " code page = " 65001 " % & gt;
& lt%
選項顯式
會話。CodePage = 65001
回應。Charset = "gb2312 "
回應。過期時間= -1
回應。AddHeader“雜註”,“無緩存”
回應。AddHeader "cache-ctrol "," no-cache "
類NetRube_VerifyCode
Public GlobalColorTable(),LocalColorTable()
Public TransparentColorIndex,UseTransparency
公共GIF89a
公眾意見
私有FGroundColorIndex,BGroundColorIndex
私人形象
Private GlobalColorTableSize,GlobalColorTableFlag,LocalColorTableSize,LocalColorTableFlag
專用寬度_,高度_
私人左側位置,頂部位置
私有位,顏色分辨率,代碼大小
私有像素比例
私有SortFlag,InterlaceFlag
專用分隔符,圖形控制,內嵌式圖像
私人保留
專用字體
私信(19)
私有子類_Initialize()
圖像= " "
GIF89a = False
ReDim GlobalColorTable(256)
GlobalColorTableSize = 7
GlobalColorTableFlag = True
GlobalColorTable(2) = RGB(255,0,0)
GlobalColorTable(3) = RGB(0,255,0)
GlobalColorTable(4) = RGB(0,0,255)
GlobalColorTable(5) = RGB(255,255,0)
GlobalColorTable(6) = RGB(0,255,255)
GlobalColorTable(7) = RGB(255,0,255)
ReDim LocalColorTable(0)
LocalColorTableSize = 0
LocalColorTableFlag = False
ColorResolution = 7
位= 7
代碼大小= 7
BGroundColorIndex = 0
FGroundColorIndex = 1
TransparentColorIndex = 0
UseTransparency = False
左位置= 0
頂部位置= 0
寬度_ = 20
高度_ = 20
清楚的
PixelAspectRatio = 0
SortFlag = False
InterlaceFlag = False
Seperator = Asc(",")
GraphicControl = Asc("!")
endo fimage = Asc(";")
評論= " "
保留= 0
設置Font = Server。CreateObject("腳本。字典》)
字母(0) = "0000000000000 "
字母(1)= " 00001111100000 "
信(2)= " 000111111110000 "
信(3)= " 00111000111000 "
信(4)= " 0011000011100 "
信(5)= " 0111000001100 "
信(6)= " 0110000001110 "
信(7)= " 0110000001110 "
信(8)= " 1110000001110 "
信(9)= " 110000001110 "
信(10)= " 110000001110 "
信(11)= " 111000001110 "
信(12)= " 1110000001100 "
信(13)= " 1110000001100 "
信(14)= " 011000001100 "
信(15)= " 01110000111100 "
信(15)= " 0011100011000 "
信(16)= " 00011111110000 "
信(17)= " 00001111100000 "
字母(18) = "000000000000 "
字體。添加“0”,字母
字母(0) = "0000000000000 "
字母(1)= " 0000001110000 "
信(2)= " 00000001110000 "
信(3)= " 00000011100000 "
字母(4) = "00000011000000 "
信(5) = "00000011000000 "
信(6) = "00000011000000 "
信(7)= " 00000111000000 "
字母(8)= " 00000111000000 "
信(9)= " 00000111000000 "
字母(10)= " 0000011000000 "
信(11)= " 0000011000000 "
信(12)= " 0000011000000 "
信(13)= " 0000011000000 "
信(14)= " 0000011000000 "
信(15)= " 0000011000000 "
信(15)= " 0000011000000 "
信(16)= " 0000011000000 "
信(17)= " 0000010000000 "
字母(18) = "000000000000 "
字體。添加“1”,字母
字母(0) = "0000000000000 "
信(1)= " 000011111110000 "
信(2)= " 00011111111000 "
信(3)= " 00111000011100 "
信(4)= " 0111000011100 "
信(5)= " 0111000011000 "
信(6)= " 0110000011000 "
信(7)= " 0000000111000 "
字母(8)= " 00000001110000 "
信(9)= " 00000001110000 "
字母(10)= " 00000011000000 "
信(11)= " 0000111000000 "
信(12)= " 0000111000000 "
信(13)= " 000110000000 "
信(14)= " 000110000000 "
信(15)= " 0011000011100 "
信(16)= " 0111111111165438 "
信(17)= " 011111111111165438 "
信(18)= " 0111110000000 "
字母(19) = "000000000000 "
字體。添加“2”,字母
字母(0) = "0000000000000 "
信(1)= " 00001111111000 "
信(2)= " 00111111111000 "
信(3)= " 01110000111100 "
信(4)= " 0110000011000 "
信(5)= " 0100000111000 "
信(6)= " 0000000111000 "
信(7)= " 00000001110000 "
字母(8) = "00000011000000 "
信(9)= " 00000111110000 "
信(10)= " 00000100111000 "
信(11)= " 000000011100 "
信(12)= " 0000000011100 "
信(13)= " 0000000011100 "
信(14)= " 0000000011100 "
信(15)= " 0000000011000 "
信(16)= " 11100001111000 "
信(17)= " 111111111110000 "
信(18)= " 011111111100000 "
字母(19) = "000000000000 "
字體。添加“3”,字母
字母(0) = "0000000000000 "
字母(1)= " 0000000111000 "
信(2)= " 00000001111000 "
信(3)= " 00000011100000 "
信(4)= " 00000111011100 "
信(5)= " 00001110011100 "
信(6)= " 00001100011000 "
信(7)= " 00011000111000 "
信(8)= " 00111000110000 "
信(9)= " 0111000110000 "
信(10)= " 0110000110000 "
信(11)= " 0110000110000 "
信(12)= " 110001111111165438 "
信(13)= " 11111111111165438 "
信(14)= " 111111111100000 "
信(15)= " 1110001100000 "
信(16)= " 0000001110000 "
信(17)= " 0000000110000 "
信(18)= " 0000000110000 "
信(19)= " 0000000100000 "
字體。添加“4”,字母
字母(0) = "0000000000000 "
字母(1)= " 0000110000100 "
信(2)= " 0011111111110 "
信(3)= " 0011111111100 "
信(4)= " 0001111000000 "
信(5) = "0001100000000 "
信(6)= " 001110000000 "
信(7)= " 001110000000 "
信(8)= " 00111111110000 "
信(9)= " 00111111111000 "
信(10)= " 0000000011000 "
信(11)= " 000000011000 "
信(12)= " 0000000011000 "
信(13)= " 0000000011000 "
信(14)= " 0000000011000 "
信(15)= " 0000000011000 "
信(16)= " 00000001111000 "
信(17)= " 011111111110000 "
信(18)= " 0011111100000 "
信(19)= " 0000000100000 "
字體。添加“5”,字母
字母(0) = "0000000000000 "
字母(1)= " 00000011110000 "
信(2)= " 00000111100000 "
信(3)= " 0000111000000 "
信(4)= " 0001110000000 "
信(5)= " 001110000000 "
信(6) = "001100000000 "
信(7) = "001100000000 "
信(8)= " 011111111110000 "
信(9)= " 01111111111000 "
信(10)= " 0111000011100 "
信(11)= " 0110000001100 "
信(12)= " 011000001100 "
信(13)= " 011000001100 "
信(14)= " 011000001100 "
信(15)= " 01110000111100 "
信(16)= " 0011000011100 "
信(17)= " 001111111111000 "
信(18)= " 00011111110000 "
字母(19) = "000000000000 "
字體。添加“6”,字母
字母(0) = "0000000000000 "
信(1)= " 001001111111165438 "
信(2)= " 01111111111100 "
信(3)= " 01111100111100 "
字母(4)= " 0000000011000 "
信(5)= " 0000000111000 "
信(6)= " 0000000110000 "
信(7)= " 0000000110000 "
字母(8)= " 0000000110000 "
信(9)= " 00000001110000 "
信(10)= " 0000001100000 "
信(11)= " 0000001100000 "
信(12)= " 0000001100000 "
信(13)= " 0000001100000 "
信(14)= " 00000011100000 "
信(15)= " 00000011100000 "
信(16)= " 00000011100000 "
信(17)= " 0000001000000 "
信(18)= " 0000001000000 "
字母(19) = "000000000000 "
字體。添加“7”,字母
字母(0) = "0000000000000 "
信(1)= " 000011111110000 "
信(2)= " 00011111111000 "
信(3)= " 0011100011000 "
信(4)= " 0011000011000 "
信(5)= " 0111000011100 "
信(6)= " 0111000011000 "
信(7)= " 0011000011000 "
信(8)= " 0011111111000 "
信(9)= " 00011111111000 "
信(10)= " 00110001111100 "
信(11)= " 0111000001100 "
信(12)= " 0111000001100 "
信(13)= " 0110000001110 "
信(14)= " 011000001100 "
信(15)= " 011000001100 "
信(16)= " 01110000111100 "
信(17)= " 00111111111100 "
信(18)= " 00011111110000 "
字母(19) = "000000000000 "
字體。添加“8”,字母
字母(0) = "0000000000000 "
信(1)= " 000111111110000 "
信(2)= " 00111111111000 "
信(3)= " 01110000111000 "
信(4)= " 0111000011100 "
信(5)= " 0110000001100 "
信(6)= " 0110000001100 "
信(7)= " 0110000001100 "
信(8)= " 0110000001100 "
信(9)= " 0111000011100 "
信(10)= " 00111111111100 "
信(11)= " 0011111111165438 "
信(12)= " 0000000011000 "
信(13)= " 0000000011000 "
信(14)= " 0000000111000 "
信(15)= " 0000001110000 "
信(16)= " 00000011100000 "
信(17)= " 00000111000000 "
信(18)= " 0001111000000 "
字母(19) = "000000000000 "
字體。添加“9”,字母
末端接頭
私有子類_Terminate()
字體。全部刪除
設置字體=無
末端接頭
公共屬性Get Width()
寬度=寬度_
結束屬性
公共屬性獲取高度()
高度=高度_
結束屬性
公共屬性獲取版本()
version = " NetRube verify code Class 1.0 Build 20041225 "
結束屬性
公共屬性字母BGroundColor(ByVal顏色)
GlobalColorTable(0)= MakeColor(Color)
BGroundColorIndex = 0
結束屬性
公共屬性字母FGroundColor(ByVal顏色)
GlobalColorTable(1)= MakeColor(Color)
FGroundColorIndex = 1
結束屬性
公共屬性Get Pixel(ByVal PX,ByVal PY)
if(PX & gt;0和PX & lt= Width_)和(PY & gt0和PY & lt= Height_)那麽
Pixel = AscB(MidB(Image,(Width_ * (PY - 1)) + PX,1))
其他
像素= 0
如果…就會結束
結束屬性
公共屬性字母Pixel(ByVal PX,ByVal PY,PValue)
尺寸偏移
PX = Int(PX)
PY = Int(PY)
PValue = Int(PValue)
偏移=寬度_ * (PY - 1)
if(PX & gt;0和PX & lt= Width_)和(PY & gt0和PY & lt= Height_)那麽
Image = LeftB(Image,Offset+(PX-1))& amp;ChrB(PValue)和amp。RightB(Image,LenB(Image) - (Offset + PX))
如果…就會結束
結束屬性
公共子清除()
image = String(Width _ *(Height _+1)/2,ChrB(BGroundColorIndex)& amp;ChrB(BGroundColorIndex))
末端接頭
Public Sub Resize(ByVal NewWidth,ByVal NewHeight,RPreserve)
尺寸舊圖像,舊寬度,舊高度
縮小復印寬度,復印高度
維度X,Y
如果保留,則
舊圖像=圖像
舊寬度=寬度_
OldHeight = Height_
如果…就會結束
Width_ = NewWidth
高度_ =新高度
清楚的
如果保留,則
如果NewWidth & gtold width Then copy width = old width Else copy width = new width
如果NewHeight & gtold height Then copy height = old height Else copy height = new height
Width_ = NewWidth
高度_ =新高度
對於Y = 1到CopyHeight
對於X = 1到復印寬度
Pixel(X,Y) = AscB(MidB(OldImage,(OldWidth * (Y - 1)) + X,1))
然後
然後
如果…就會結束
末端接頭
私有函數ShiftLeft(SLValue,SLBits)
ShiftLeft = SLValue * (2個^ sl bit)
結束功能
私有函數ShiftRight(SRValue,SRBits)
shift right = int(Sr value/(2 ^ Sr bits))
結束功能
私有函數低電平(左值)
低=左值和& ampHFF
結束功能
私有函數高(h值)
High = ShiftRight(HValue,8)
結束功能
私有函數Blue(BValue)
藍色=低(ShiftRight(BValue,16))
結束功能
私有函數綠色(GValue)
綠色=低電平(ShiftRight(GValue,8))
結束功能
私有函數紅色(右值)
紅色=低(右值)
結束功能
私有函數MakeColor(MCValue)
make color = CLng(& amp;H " & ampRight(MCValue,2)& amp;Mid(MCValue,4,2)和ampMid(MCValue,2,2))
結束功能
私有函數GetWord(GWValue)
get word = shift left(AscB(right b(GW value,1)),8)或AscB(LeftB(GWValue,1))
結束功能
私有函數MakeWord(MWValue)
make word = ChrB(Low(MW value))& amp;ChrB(高(MWValue))
結束功能
私有函數MakeByte(MBValue)
MakeByte = ChrB(低(MBValue))
結束功能
私有函數UncompressedData()
Dim ClearCode,ChunkMax,EndOfStream
美國UD迪姆烏達塔
未壓縮數據= " "
清零代碼= 2個^位
ChunkMax = 2 ^位- 2
EndOfStream = ClearCode + 1
UDData = " "
對於U = 1到LenB(圖像)步長ChunkMax
UDData = UDData & ampMidB(Image,U,ChunkMax)清晰代碼
然後
for U = 1 To LenB(UDData)Step & amp;HFF
UD = MidB(UDData,U & amp;HFF)
未壓縮數據。MakeByte(LenB(UD))& amp;UD
然後
未壓縮數據。MakeByte(& amp;H00)
未壓縮數據。MakeByte(結束流)
結束功能
私有函數GetGColorTable()
Dim GGCT
GetGColorTable = " "
對於GGCT = 0到UBound(GlobalColorTable)-1
GetGColorTable = GetGColorTable & amp;MakeByte(紅色(GlobalColorTable(GGCT)))
GetGColorTable = GetGColorTable & amp;MakeByte(綠色(GlobalColorTable(GGCT)))
GetGColorTable = GetGColorTable & amp;MakeByte(藍色(GlobalColorTable(GGCT)))
然後
結束功能
私有函數GetLColorTable()
昏暗的GLCT
GetLColorTable = " "
對於GLCT = 0到UBound(LocalColorTable)-1
GetLColorTable = GetLColorTable & amp;MakeByte(紅色(本地顏色表(GLCT)))
GetLColorTable = GetLColorTable & amp;MakeByte(綠色(本地顏色表(GLCT)))
GetLColorTable = GetLColorTable & amp;MakeByte(藍色(本地顏色表(GLCT)))
然後
結束功能
私有函數GlobalDescriptor()
GlobalDescriptor = 0
如果GlobalColorTableFlag,則global descriptor = global descriptor或ShiftLeft(1,7)
global descriptor = global descriptor或ShiftLeft(ColorResolution,7)
if sort flag Then global descriptor = global descriptor或ShiftLeft(1,3)
global descriptor = global descriptor或GlobalColorTableSize
結束功能
私有函數LocalDescriptor()
LocalDescriptor = 0
如果LocalColorTableFlag,則local descriptor = local descriptor或ShiftLeft(1,7)
如果InterlaceFlag,則local descriptor = local descriptor或ShiftLeft(1,6)
如果SortFlag,則local descriptor = local descriptor或ShiftLeft(1,5)
local descriptor = local descriptor或ShiftLeft(保留,3)
local descriptor = local descriptor或LocalColorTableSize
結束功能
私有屬性Get ImageData()
昏暗的文字,我
ImageData = GIFHeader
ImageData = ImageData & amp造詞(寬度_)
ImageData = ImageData & amp造詞(高度_)
ImageData = ImageData & ampMakeByte(全局描述符)
ImageData = ImageData & ampMakeByte(BGroundColorIndex)
ImageData = ImageData & ampMakeByte(pixelaspecratio)
ImageData = ImageData & ampGetGColorTable
如果GIF89a那麽
如果使用透明,那麽
ImageData = ImageData & ampMakeByte(圖形控制)
ImageData = ImageData & ampMakeByte(& amp;HF9)
ImageData = ImageData & ampMakeByte(& amp;H04)
ImageData = ImageData & ampMakeByte(& amp;H01)
ImageData = ImageData & ampMakeByte(& amp;H00)
ImageData = ImageData & ampMakeByte(TransparentColorIndex)
ImageData = ImageData & ampMakeByte(& amp;H00)
如果…就會結束
如果評論& lt& gt”“那麽
ImageData = ImageData & ampMakeByte(圖形控制)
ImageData = ImageData & ampMakeByte(& amp;HFE)
Text = Left(註釋& ampHFF)
ImageData = ImageData & ampMakeByte(Len(Text))
For I = 1 To Len(Text)
ImageData = ImageData & ampMakeByte(Asc(Mid(Text,I,1)))
然後
ImageData = ImageData & ampMakeByte(& amp;H00)
如果…就會結束
如果…就會結束
ImageData = ImageData & ampMakeByte(分隔符)
ImageData = ImageData & amp造字(左定位)
ImageData = ImageData & amp造詞(頂端位置)
ImageData = ImageData & amp造詞(寬度_)
ImageData = ImageData & amp造詞(高度_)
ImageData = ImageData & ampMakeByte(本地描述符)
ImageData = ImageData & ampMakeByte(代碼大小)
ImageData = ImageData & amp未壓縮數據
ImageData = ImageData & ampMakeByte(& amp;H00)
ImageData = ImageData & ampMakeByte(結束圖像)
結束屬性
公共Sub Write()
回應。ContentType = "image/gif "
回應。二進制寫圖像數據
末端接頭
私有函數GIFHeader()
GIFHeader = " "
GIFHeader = GIFHeader & ampChrB(Asc("G "))
GIFHeader = GIFHeader & ampChrB(Asc("I "))
GIFHeader = GIFHeader & ampChrB(Asc("F "))
GIFHeader = GIFHeader & ampChrB(Asc("8 "))
如果GIF89a,那麽GIFHeader = GIFHeader & ampChrB(Asc(" 9 "))Else gif header = gif header & amp;ChrB(Asc(" 7 ")End If
GIFHeader = GIFHeader & ampChrB(Asc("a "))
結束功能
公共子驗證碼(文本,VCColor)
Dim I1,I2,I3
迪姆·VCX,VCY,VCIndex
Resize 14 * Len(文本)+ 10,UBound(字母)+ 10,False
使不規則化
VCX = Int(Rnd * 10)
VCY = Int(Rnd *(高度_ - UBound(字母)))
對於I1 = 0到UBound(字母)- 1
對於I2 = 1到Len(文本)
for I3 = 1 To Len(Font(Mid(Text,I2,1))(I1))
VCIndex = CLng(Mid(Font(Mid(Text,I2,1))(I1),I3,1))
如果VCIndex & lt& gt那麽0
如果VCColor那麽
使不規則化
VCIndex = Int(Rnd * 7)
如果…就會結束
Pixel(VCX + ((I2 - 1) * Len(字母(0))+I3,VCY + I1) = VCIndex
如果…就會結束
然後
然後
然後
末端接頭
公共子噪聲(數量、顏色)
Dim NI,NIndex
對於NI = 1地金額
NIndex = 1
如果NColor那麽
使不規則化
NIndex = Int(Rnd * 7)
如果…就會結束
Pixel(Int(Rnd * Width_),Int(Rnd * Height _)= NIndex
然後
末端接頭
結束類
% & gt
showcode.asp
& lt!-# include file = " verify code . ASP "-& gt;
& lt%
Dim VC,代碼
使不規則化
設置VC = New NetRube_VerifyCode
使用VC
選擇案例請求。QueryString("type ")
案例“2”
code = Int(Rnd * 900000+100000)
會話(" VerifyCode") =代碼
。BGroundColor = "#FFFF00 "
。FGroundColor = "#FF0000 "
。VerifyCode代碼,假
。噪聲100,假
。寫
案例“3”
Code = Int(Rnd * 90000 + 10000)
會話(" VerifyCode") =代碼
。BGroundColor = "#000000 "
。FGroundColor = "#FFFFFF "
。VerifyCode代碼,假
。噪音50,真的
。寫
案件“4”
code = Int(Rnd * 900000+100000)
會話(" VerifyCode") =代碼
。BGroundColor = "#FFFFFF "
。FGroundColor = "#000000 "
。驗證代碼代碼,真
。噪聲100,真
。寫
其他情況
Code = Int(Rnd * 90000 + 10000)
會話(" VerifyCode") =代碼
。' BGroundColor = "#FFFFFF " '
。' FGroundColor = "#000000 " '
。'驗證碼代碼,假'
。噪聲50,假'
。“寫”
結束選擇
以…結尾
設置VC =無
% & gt
以上兩個文件是必須的。當使用它們時,寫下其中type是定義的變量,代表本系統支持的驗證碼類型,包括壹* * *四種類型:
1,白色背景,黑色文字,50個單色斑點,5位驗證碼。
2、黃色背景,紅色文字,100單色雜亂,6位驗證碼。
3、黑色背景,白色文字,50色噪聲,5位驗證碼
4,白底,彩色文字,100色噪,6位驗證碼。
類型的對應值是1,2,3,4。
檢索已填寫的驗證碼,並將其與會話(“VerifyCode”)進行比較。如果壹致,驗證碼是正確的,否則就是錯誤的!!