ASP實現加法驗證碼_應用技巧

來源:互聯網
上載者:User

將驗證碼改為加法運算,比如驗證碼顯示“25+64等於?”,那麼輸入“91”就能通過驗證。
來看看效果圖對比:字元驗證碼: → 加法驗證碼:
優點:
①與純字元驗證碼相比,本程式效防止了絕大部分(99%以上)廣告機的自動識別。即使是中文驗證碼, 也能被市面上的部分廣告機識別。
②與中文驗證碼相比,避免了使用者輸入使用者名稱密碼驗證碼的時候需要切換IME的麻煩。
說明:該程式需要網站空間支援ASPJpeg組件、楷體_GB2312字型。
代碼如下:

<%Const FontColor = &H000000 ' 字型顏色Const BgColor = &HFFCCFF ' 背景顏色Call CreatValidCode("GetCode")Sub CreatValidCode(pSN)  Dim x, Jpeg  Randomize  x = Array(1+Int(Rnd()*9), Int(Rnd()*10), 1+Int(Rnd()*9), Int(Rnd()*10), 0, 0, "+")  x(4) = x(0)*10 + x(1)  x(5) = x(2)*10 + x(3)  'Session(pSN) = CStr(Eval(x(4) & x(6) & x(5)))  Session(pSN) = CStr(x(4) + x(5))  Set Jpeg = Server.CreateObject("Persits.Jpeg")  Jpeg.New 100,20,BgColor  Jpeg.Quality=100  With Jpeg.Canvas    .Font.Bold = True    .Font.Size = 16    .Font.Rotation = 0    .Font.Family = "楷體_GB2312"    .Font.Color = FontColor    .PrintText 4, 3, CStr(x(0))    .PrintText 14, 3, CStr(x(1))    .PrintText 26, 3, x(6)    .PrintText 38, 3, CStr(x(2))    .PrintText 48, 3, CStr(x(3))    .Font.Rotation = 15    .PrintText 55, 3, "等"    .PrintText 70, 3, "於"    .PrintText 85, 3, "?"  End With  '禁止緩衝  Response.ContentType = "image/jpeg"  Response.Expires = -9999  Response.AddHeader "pragma", "no-cache"  Response.AddHeader "cache-ctrol", "no-cache"  Response.AddHeader "Content-Disposition","inline; filename=vcode.jpg"  Jpeg.SendBinary  Jpeg.Close  Set Jpeg = NothingEnd Sub%>

以上就是關於asp實現加法驗證碼的關鍵代碼,有興趣的朋友,還可以擴充為其他的運算,比如乘法,減法,乘方等,希望本文對大家的學習有所協助。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.