asp生成數(shù)字圖片驗(yàn)證碼
來(lái)源:易賢網(wǎng) 閱讀:3354 次 日期:2014-08-26 10:31:58
溫馨提示:易賢網(wǎng)小編為您整理了“asp生成數(shù)字圖片驗(yàn)證碼”,方便廣大網(wǎng)友查閱!

查看效果:asp生成圖片驗(yàn)證碼

調(diào)用代碼和刷新驗(yàn)證碼代碼

<a href="javascript:f()"><img src="yzm.asp" name="yzm" id="yzm" alt="點(diǎn)擊更換"></a>

<script>

function f()

{document.getElementById("yzm").src="yzm.asp";}

</script>

圖片驗(yàn)證碼代碼:

<%

Option Explicit

Response.Expires = 0

Response.AddHeader "Pragma","no-cache"

Response.AddHeader "cache-ctrol","no-cache"

Response.ContentType = "Image/BMP"

Randomize Timer

Dim Text_Data(9),Text_Len,Int_Temp(),I,j,k,Int_Temp2

''***** 參數(shù)配置區(qū) *****

Text_Len = 4 ''驗(yàn)證碼長(zhǎng)度(支持1-25位)

''**********************

ReDim Int_Temp( Text_Len - 1 )

Text_Data(0) = "00000000000001111000001100110000110111000011011100001100110000111011000011101100001100110000011110000000000000"

Text_Data(1) = "00000000000000011000000011100000111110000000011000000001100000000110000000011000000001100000000110000000000000"

Text_Data(2) = "00000000000001111000001100110000110011000000001100000001100000001100000001100000001100000000111111000000000000"

Text_Data(3) = "00000000000001111000001100110000110011000000001100000011100000000011000011001100001100110000011110000000000000"

Text_Data(4) = "00000000000001100000000110000000011011000001101100000110110000110011000011111110000000110000000011000000000000"

Text_Data(5) = "00000000000011111100001100000000110000000011000000001111100000000011000000001100000001100000111100000000000000"

Text_Data(6) = "00000000000000111000000011000000011000000011111000001100110000110011000011001100001100110000011110000000000000"

Text_Data(7) = "00000000000011111100000000110000000110000000011000000011000000001100000001100000000110000000011000000000000000"

Text_Data(8) = "00000000000001111000001100110000110011000011101100000111100000110111000011001100001100110000011110000000000000"

Text_Data(9) = "00000000000001111000001100110000110011000011001100001100110000011111000000011000000011000000011100000000000000"

''下面隨機(jī)生成各位驗(yàn)證碼

Session("Num") = ""

For I = 0 To Text_Len - 1

Int_Temp(I) = Int(Rnd * 10)

Session("Num") = Session("Num") + Mid("0123456789",Int_Temp(I)+1,1)

Next

''下面輸出文件頭部分

Int_Temp2 = (Text_Len - 1) \ 4 * 220 + ((Text_Len - 1) / 4 - (Text_Len - 1) \ 4 * 4) * 44

Response.BinaryWrite ChrB(&H42) & ChrB(&H4D)

Response.BinaryWrite ChrB(((Int_Temp2 + 206) / 256 - (Int_Temp2 + 206) \ 256) * 256) & ChrB((Int_Temp2 + 206) \ 256) ''特殊位

Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H76) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H28) & ChrB(0) & ChrB(0) & ChrB(0)

Response.BinaryWrite ChrB(Text_Len * 10) ''特殊位

Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&HB) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H1) & ChrB(0) & ChrB(&H4) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0)

Response.BinaryWrite ChrB(((Int_Temp2 + 88) / 256 - (Int_Temp2 + 88) \ 256) * 256) & ChrB((Int_Temp2 + 88) \ 256) ''特殊位

Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(16) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(16) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(&H80) & ChrB(0) & ChrB(&H80) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(0) & ChrB(&H80) & ChrB(0)

Response.BinaryWrite ChrB(&H80) & ChrB(&H80) & ChrB(0) & ChrB(0) & ChrB(&H80) & ChrB(&H80) & ChrB(&H80) & ChrB(0) & ChrB(&HC0) & ChrB(&HC0) & ChrB(&HC0) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(&HFF) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(&HFF) & ChrB(0) & ChrB(&HFF) & ChrB(&HFF) & ChrB(0) & ChrB(0) & ChrB(&HFF) & ChrB(&HFF) & ChrB(&HFF) & ChrB(0)

''下面輸出圖片數(shù)據(jù)

For i = 10 to 0 Step -1

For j = 0 to Text_Len - 1

For k = 1 to 9 Step 2

If Mid(Text_Data(Int_Temp(j)) , i * 10 + k , 1) = "0" Then Int_Temp2 = Get_BackColor() * 16 Else Int_Temp2 = Get_ForeColor() * 16

If Mid(Text_Data(Int_Temp(j)) , i * 10 + k + 1 , 1) = "0" Then Int_Temp2 = Int_Temp2 + Get_BackColor() Else Int_Temp2 = Int_Temp2 + Get_ForeColor()

Response.BinaryWrite ChrB(Int_Temp2)

Next

Next

Int_Temp2 = (Text_Len / 4 - Text_Len \ 4) * 4

Select Case Int_Temp2

Case 1

Response.BinaryWrite ChrB(0) & ChrB(0) & ChrB(0)

Case 2

Response.BinaryWrite ChrB(0) & ChrB(0)

Case 3

Response.BinaryWrite ChrB(0)

End Select

Next

Function Get_BackColor()

''得到一個(gè)背景色

If Int(Rnd * 30) = 0 Then ''注:此處的 Rnd * 30 是決定背景雜色的多少,值越大,則雜色越少,圖片越容易看清楚

Get_BackColor = CInt(Mid("00021209",Int(Rnd * 4) * 2 + 1,2))

Else

Get_BackColor = CInt(Mid("081515151515",Int(Rnd * 6) * 2 + 1,2))

End If

End Function

Function Get_ForeColor()

''得到一個(gè)前景色

Get_ForeColor = CInt(Mid("00021209",Int(Rnd * 4) * 2 + 1,2))

End Function

%>

更多信息請(qǐng)查看IT技術(shù)專欄

更多信息請(qǐng)查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:asp生成數(shù)字圖片驗(yàn)證碼
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國(guó)考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)