MSG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
D:\Temp\找图片图标\验证码\Code_5.asp 编码GB2312
<%  '************************************************************  '作者:云端  '版权:源代码公开,各种用途均可免费使用。  '创建:2013-11-16  '联系:QQ313801120 交流群35915100 邮箱313801120@qq.com  '* Powered By 云端  '************************************************************  Option Explicit  'Session.CodePage = 65001  'Response.Charset = "UTF-8"  Response.Expires = -1  Response.AddHeader "Pragma", "no-cache"  Response.AddHeader "cache-ctrol", "no-cache"  Dim VC, Code  Randomize  Set VC = New NetRube_VerifyCode With VC Code = Int(Rnd * 9000 + 1000)  Session("firstecode") = "" & Code  .BGroundColor = "#14426F" '图片背景颜色  .FGroundColor = "#ffffff" '前景(文本)颜色  .VerifyCode Code, False 'False ' 处理验证码,第二个参数为是否显示彩色文本  .Noises 50, True '添加杂点,第一个参数为杂点数量,第二个参数为是否显示彩色杂点  .Write '输出图片  End With  Set VC = Nothing  Class NetRube_VerifyCode Public GlobalColorTable(), LocalColorTable()  Public TransparentColorIndex, UseTransparency  Public GIF89a  Public Comment  Private FGroundColorIndex, BGroundColorIndex  Private Image  Private GlobalColorTableSize, GlobalColorTableFlag, LocalColorTableSize, LocalColorTableFlag  Private Width_, Height_  Private LeftPosition, TopPosition  Private Bits, ColorResolution, CodeSize  Private PixelAspectRatio  Private SortFlag, InterlaceFlag  Private Seperator, GraphicControl, EndOfImage  Private Reserved  Private Font  Private Letter(19) 
Private Sub Class_Initialize() Image = ""  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  Bits = 7  CodeSize = 7  BGroundColorIndex = 0  FGroundColorIndex = 1  TransparentColorIndex = 0  UseTransparency = False  LeftPosition = 0  TopPosition = 0  Width_ = 20  Height_ = 20  Clear  PixelAspectRatio = 0  SortFlag = False  InterlaceFlag = False  Seperator = Asc(",")  GraphicControl = Asc("!")  EndOfImage = Asc(";")  Comment = ""  Reserved = 0  Set Font = Server.CreateObject("Scripting.Dictionary") Letter(0) = "00000000000000"  Letter(1) = "00001111100000"  Letter(2) = "00011111110000"  Letter(3) = "00111000111000"  Letter(4) = "00110000011100"  Letter(5) = "01110000001100"  Letter(6) = "01100000001110"  Letter(7) = "01100000001110"  Letter(8) = "11100000001110"  Letter(9) = "11000000001110"  Letter(10) = "11000000001110"  Letter(11) = "11100000001110"  Letter(12) = "11100000001100"  Letter(13) = "11100000001100"  Letter(14) = "01100000001100"  Letter(15) = "01110000011100"  Letter(15) = "00111000011000"  Letter(16) = "00011111110000"  Letter(17) = "00001111100000"  Letter(18) = "00000000000000"  Font.Add "0", Letter  Letter(0) = "00000000000000"  Letter(1) = "00000001110000"  Letter(2) = "00000001110000"  Letter(3) = "00000011100000"  Letter(4) = "00000011000000"  Letter(5) = "00000011000000"  Letter(6) = "00000011000000"  Letter(7) = "00000111000000"  Letter(8) = "00000111000000"  Letter(9) = "00000111000000"  Letter(10) = "00000110000000"  Letter(11) = "00000110000000"  Letter(12) = "00000110000000"  Letter(13) = "00000110000000"  Letter(14) = "00000110000000"  Letter(15) = "00000110000000"  Letter(15) = "00000110000000"  Letter(16) = "00000110000000"  Letter(17) = "00000010000000"  Letter(18) = "00000000000000"  Font.Add "1", Letter  Letter(0) = "00000000000000"  Letter(1) = "00001111110000"  Letter(2) = "00011111111000"  Letter(3) = "00111000011100"  Letter(4) = "01110000011100"  Letter(5) = "01110000011000"  Letter(6) = "01100000011000"  Letter(7) = "00000000111000"  Letter(8) = "00000001110000"  Letter(9) = "00000001110000"  Letter(10) = "00000011000000"  Letter(11) = "00000111000000"  Letter(12) = "00001110000000"  Letter(13) = "00011000000000"  Letter(14) = "00011000000000"  Letter(15) = "00110000011100"  Letter(16) = "01101111111100"  Letter(17) = "01111111111110"  Letter(18) = "01111100000000"  Letter(19) = "00000000000000"  Font.Add "2", Letter  Letter(0) = "00000000000000"  Letter(1) = "00001111111000"  Letter(2) = "00111111111000"  Letter(3) = "01110000111100"  Letter(4) = "01100000011000"  Letter(5) = "01000000111000"  Letter(6) = "00000000111000"  Letter(7) = "00000001110000"  Letter(8) = "00000011000000"  Letter(9) = "00000111110000"  Letter(10) = "00000100111000"  Letter(11) = "00000000011100"  Letter(12) = "00000000011100"  Letter(13) = "00000000011100"  Letter(14) = "00000000011100"  Letter(15) = "00000000011000"  Letter(16) = "11100000111000"  Letter(17) = "11111111110000"  Letter(18) = "01111111100000"  Letter(19) = "00000000000000"  Font.Add "3", Letter  Letter(0) = "00000000000000"  Letter(1) = "00000000111000"  Letter(2) = "00000001111000"  Letter(3) = "00000011100000"  Letter(4) = "00000111011100"  Letter(5) = "00001110011100"  Letter(6) = "00001100011000"  Letter(7) = "00011000111000"  Letter(8) = "00111000110000"  Letter(9) = "01110000110000"  Letter(10) = "01100000110000"  Letter(11) = "01100000110000"  Letter(12) = "11000111111110"  Letter(13) = "11111111111100"  Letter(14) = "11111111100000"  Letter(15) = "11100001100000"  Letter(16) = "00000001110000"  Letter(17) = "00000000110000"  Letter(18) = "00000000110000"  Letter(19) = "00000000100000"  Font.Add "4", Letter  Letter(0) = "00000000000000"  Letter(1) = "00001100000100"  Letter(2) = "00011111111110"  Letter(3) = "00011111111100"  Letter(4) = "00011110000000"  Letter(5) = "00011000000000"  Letter(6) = "00111000000000"  Letter(7) = "00111000000000"  Letter(8) = "00111111110000"  Letter(9) = "00111111111000"  Letter(10) = "00000000011000"  Letter(11) = "00000000011000"  Letter(12) = "00000000011000"  Letter(13) = "00000000011000"  Letter(14) = "00000000011000"  Letter(15) = "00000000011000"  Letter(16) = "00000001111000"  Letter(17) = "01111111110000"  Letter(18) = "00111111000000"  Letter(19) = "00000000100000"  Font.Add "5", Letter  Letter(0) = "00000000000000"  Letter(1) = "00000011110000"  Letter(2) = "00000111100000"  Letter(3) = "00001110000000"  Letter(4) = "00011100000000"  Letter(5) = "00111000000000"  Letter(6) = "00110000000000"  Letter(7) = "00110000000000"  Letter(8) = "01111111110000"  Letter(9) = "01111111111000"  Letter(10) = "01110000011100"  Letter(11) = "01100000001100"  Letter(12) = "01100000001100"  Letter(13) = "01100000001100"  Letter(14) = "01100000001100"  Letter(15) = "01110000011100"  Letter(16) = "00110000011100"  Letter(17) = "00111111111000"  Letter(18) = "00011111110000"  Letter(19) = "00000000000000"  Font.Add "6", Letter  Letter(0) = "00000000000000"  Letter(1) = "00100111111110"  Letter(2) = "01111111111100"  Letter(3) = "01111110011100"  Letter(4) = "00000000011000"  Letter(5) = "00000000111000"  Letter(6) = "00000000110000"  Letter(7) = "00000000110000"  Letter(8) = "00000000110000"  Letter(9) = "00000001110000"  Letter(10) = "00000001100000"  Letter(11) = "00000001100000"  Letter(12) = "00000001100000"  Letter(13) = "00000001100000"  Letter(14) = "00000011100000"  Letter(15) = "00000011100000"  Letter(16) = "00000011100000"  Letter(17) = "00000001000000"  Letter(18) = "00000001000000"  Letter(19) = "00000000000000"  Font.Add "7", Letter  Letter(0) = "00000000000000"  Letter(1) = "00001111110000"  Letter(2) = "00011111111000"  Letter(3) = "00111000011000"  Letter(4) = "00110000011000"  Letter(5) = "01110000011100"  Letter(6) = "01110000011000"  Letter(7) = "00110000011000"  Letter(8) = "00111101111000"  Letter(9) = "00011111111000"  Letter(10) = "00111000111100"  Letter(11) = "01110000001100"  Letter(12) = "01110000001100"  Letter(13) = "01100000001110"  Letter(14) = "01100000001100"  Letter(15) = "01100000001100"  Letter(16) = "01110000011100"  Letter(17) = "00111111111100"  Letter(18) = "00011111110000"  Letter(19) = "00000000000000"  Font.Add "8", Letter  Letter(0) = "00000000000000"  Letter(1) = "00011111110000"  Letter(2) = "00111111111000"  Letter(3) = "01110000111000"  Letter(4) = "01110000011100"  Letter(5) = "01100000001100"  Letter(6) = "01100000001100"  Letter(7) = "01100000001100"  Letter(8) = "01100000001100"  Letter(9) = "01110000011100"  Letter(10) = "00111111111100"  Letter(11) = "00011111111100"  Letter(12) = "00000000011000"  Letter(13) = "00000000011000"  Letter(14) = "00000000111000"  Letter(15) = "00000001110000"  Letter(16) = "00000011100000"  Letter(17) = "00000111000000"  Letter(18) = "00011110000000"  Letter(19) = "00000000000000"  Font.Add "9", Letter  End Sub
Private Sub Class_Terminate() Font.RemoveAll  Set Font = Nothing  End Sub
  Public Property Get Width() Width = Width_  End Property  Public Property Get Height() Height = Height_  End Property  Public Property Get Version() Version = "NetRube VerifyCode Class 1.0 Build 20041225"  End Property  Public Property Let BGroundColor(ByVal Color) GlobalColorTable(0) = MakeColor(Color)  BGroundColorIndex = 0  End Property  Public Property Let FGroundColor(ByVal Color) GlobalColorTable(1) = MakeColor(Color)  FGroundColorIndex = 1  End Property  Public Property Get Pixel(ByVal Px, ByVal Py) If(Px > 0 And Px <= Width_) And(Py > 0 And Py <= Height_) Then Pixel = AscB(MidB(Image,(Width_ * (Py - 1)) + Px, 1))  Else Pixel = 0  End If  End Property  Public Property Let Pixel(ByVal Px, ByVal Py, PValue) Dim OffSet  Px = Int(Px)  Py = Int(Py)  PValue = Int(PValue)  OffSet = Width_ * (Py - 1)  If(Px > 0 And Px <= Width_) And(Py > 0 And Py <= Height_) Then Image = LeftB(Image, OffSet + (Px - 1)) & ChrB(PValue) & RightB(Image, LenB(Image) - (OffSet + Px))  End If  End Property 
Public Sub Clear() Image = String(Width_ * (Height_ + 1) / 2, ChrB(BGroundColorIndex) & ChrB(BGroundColorIndex))  End Sub
 
Public Sub Resize(ByVal NewWidth, ByVal NewHeight, RPreserve) Dim OldImage, OldWidth, OldHeight  Dim CopyWidth, CopyHeight  Dim X, Y  If RPreserve Then OldImage = Image  OldWidth = Width_  OldHeight = Height_  End If  Width_ = NewWidth  Height_ = NewHeight  Clear  If RPreserve Then If NewWidth > OldWidth Then CopyWidth = OldWidth Else CopyWidth = NewWidth  If NewHeight > OldHeight Then CopyHeight = OldHeight Else CopyHeight = NewHeight  Width_ = NewWidth  Height_ = NewHeight  For Y = 1 To CopyHeight For X = 1 To CopyWidth Pixel(X, Y) = AscB(MidB(OldImage,(OldWidth * (Y - 1)) + X, 1))  Next  Next  End If  End Sub
 
Private Function ShiftLeft(SLValue, SLBits) ShiftLeft = SLValue * (2 ^ SLBits)  End Function
 
Private Function ShiftRight(SRValue, SRBits) ShiftRight = Int(SRValue / (2 ^ SRBits))  End Function
 
Private Function Low(LValue) Low = LValue And &HFF  End Function
 
Private Function High(HValue) High = ShiftRight(HValue, 8)  End Function
 
Private Function Blue(BValue) Blue = Low(ShiftRight(BValue, 16))  End Function
 
Private Function Green(GValue) Green = Low(ShiftRight(GValue, 8))  End Function
 
Private Function Red(RValue) Red = Low(RValue)  End Function
 
Private Function MakeColor(MCValue) MakeColor = CLng("&H" & Right(MCValue, 2) & Mid(MCValue, 4, 2) & Mid(MCValue, 2, 2))  End Function
 
Private Function GetWord(GWValue) GetWord = ShiftLeft(AscB(RightB(GWValue, 1)), 8) Or AscB(LeftB(GWValue, 1))  End Function
 
Private Function MakeWord(MWValue) MakeWord = ChrB(Low(MWValue)) & ChrB(High(MWValue))  End Function
 
Private Function MakeByte(MBValue) MakeByte = ChrB(Low(MBValue))  End Function
 
Private Function UncompressedData() Dim ClearCode, ChunkMax, EndOfStream  Dim UDData, UD, U  UncompressedData = ""  ClearCode = 2 ^ Bits  ChunkMax = 2 ^ Bits - 2  EndOfStream = ClearCode + 1  UDData = ""  For U = 1 To LenB(Image) Step ChunkMax UDData = UDData & MidB(Image, U, ChunkMax) & ChrB(ClearCode)  Next  For U = 1 To LenB(UDData) Step &HFF UD = MidB(UDData, U, &HFF)  UncompressedData = UncompressedData & MakeByte(LenB(UD)) & UD  Next  UncompressedData = UncompressedData & MakeByte( &H00)  UncompressedData = UncompressedData & MakeByte(EndOfStream)  End Function
 
Private Function GetGColorTable() Dim GGCT  GetGColorTable = ""  For GGCT = 0 To UBound(GlobalColorTable) - 1 GetGColorTable = GetGColorTable & MakeByte(Red(GlobalColorTable(GGCT)))  GetGColorTable = GetGColorTable & MakeByte(Green(GlobalColorTable(GGCT)))  GetGColorTable = GetGColorTable & MakeByte(Blue(GlobalColorTable(GGCT)))  Next  End Function
 
Private Function GetLColorTable() Dim GLCT  GetLColorTable = ""  For GLCT = 0 To UBound(LocalColorTable) - 1 GetLColorTable = GetLColorTable & MakeByte(Red(LocalColorTable(GLCT)))  GetLColorTable = GetLColorTable & MakeByte(Green(LocalColorTable(GLCT)))  GetLColorTable = GetLColorTable & MakeByte(Blue(LocalColorTable(GLCT)))  Next  End Function
 
Private Function GlobalDescriptor() GlobalDescriptor = 0  If GlobalColorTableFlag Then GlobalDescriptor = GlobalDescriptor Or ShiftLeft(1, 7)  GlobalDescriptor = GlobalDescriptor Or ShiftLeft(ColorResolution, 7)  If SortFlag Then GlobalDescriptor = GlobalDescriptor Or ShiftLeft(1, 3)  GlobalDescriptor = GlobalDescriptor Or GlobalColorTableSize  End Function
 
Private Function LocalDescriptor() LocalDescriptor = 0  If LocalColorTableFlag Then LocalDescriptor = LocalDescriptor Or ShiftLeft(1, 7)  If InterlaceFlag Then LocalDescriptor = LocalDescriptor Or ShiftLeft(1, 6)  If SortFlag Then LocalDescriptor = LocallDescriptor Or ShiftLeft(1, 5)  LocalDescriptor = LocalDescriptor Or ShiftLeft(Reserved, 3)  LocalDescriptor = LocalDescriptor Or LocalColorTableSize  End Function
  Private Property Get ImageData() Dim Text, I  ImageData = GIFHeader  ImageData = ImageData & MakeWord(Width_)  ImageData = ImageData & MakeWord(Height_)  ImageData = ImageData & MakeByte(GlobalDescriptor)  ImageData = ImageData & MakeByte(BGroundColorIndex)  ImageData = ImageData & MakeByte(PixelAspectRatio)  ImageData = ImageData & GetGColorTable  If GIF89a Then If UseTransparency Then ImageData = ImageData & MakeByte(GraphicControl)  ImageData = ImageData & MakeByte( &HF9)  ImageData = ImageData & MakeByte( &H04)  ImageData = ImageData & MakeByte( &H01)  ImageData = ImageData & MakeByte( &H00)  ImageData = ImageData & MakeByte(TransparentColorIndex)  ImageData = ImageData & MakeByte( &H00)  End If  If Comment <> "" Then ImageData = ImageData & MakeByte(GraphicControl)  ImageData = ImageData & MakeByte( &HFE)  Text = Left(Comment, &HFF)  ImageData = ImageData & MakeByte(Len(Text))  For I = 1 To Len(Text) ImageData = ImageData & MakeByte(Asc(Mid(Text, I, 1)))  Next  ImageData = ImageData & MakeByte( &H00)  End If  End If  ImageData = ImageData & MakeByte(Seperator)  ImageData = ImageData & MakeWord(LeftPosition)  ImageData = ImageData & MakeWord(TopPosition)  ImageData = ImageData & MakeWord(Width_)  ImageData = ImageData & MakeWord(Height_)  ImageData = ImageData & MakeByte(LocalDescriptor)  ImageData = ImageData & MakeByte(CodeSize)  ImageData = ImageData & UncompressedData  ImageData = ImageData & MakeByte( &H00)  ImageData = ImageData & MakeByte(EndOfImage)  End Property 
Public Sub Write() Response.ContentType = "image/gif"  Response.BinaryWrite ImageData  End Sub
 
Private Function GIFHeader() GIFHeader = ""  GIFHeader = GIFHeader & ChrB(Asc("G"))  GIFHeader = GIFHeader & ChrB(Asc("I"))  GIFHeader = GIFHeader & ChrB(Asc("F"))  GIFHeader = GIFHeader & ChrB(Asc("8"))  If GIF89a Then GIFHeader = GIFHeader & ChrB(Asc("9")) Else GIFHeader = GIFHeader & ChrB(Asc("7")) End If  GIFHeader = GIFHeader & ChrB(Asc("a"))  End Function
 
Public Sub VerifyCode(Text, VCColor) Dim I1, I2, I3  Dim VCX, VCY, VCIndex  Resize 14 * Len(Text) + 10, UBound(Letter) + 10, False  Randomize  VCX = Int(Rnd * 10)  VCY = Int(Rnd * (Height_ - UBound(Letter)))  For I1 = 0 To UBound(Letter) - 1 For I2 = 1 To Len(Text) For I3 = 1 To Len(Font(Mid(Text, I2, 1))(I1)) VCIndex = CLng(Mid(Font(Mid(Text, I2, 1))(I1), I3, 1))  If VCIndex <> 0 Then If VCColor Then Randomize  VCIndex = Int(Rnd * 7)  End If  Pixel(VCX + ((I2 - 1) * Len(Letter(0))) + I3, VCY + I1) = VCIndex  End If  Next  Next  Next  End Sub
 
Public Sub Noises(Amount, NColor) Dim NI, NIndex  For NI = 1 To Amount NIndex = 1  If NColor Then Randomize  NIndex = Int(Rnd * 7)  End If  Pixel(Int(Rnd * Width_), Int(Rnd * Height_)) = NIndex  Next  End Sub
  End Class  %>
 
隐藏注释
正常版
简洁版
简洁去注释
代码不变版
复制代码