A super Simple ASP Generation Verification Code program

Source: Internet
Author: User

<%
Sub Getsafecode
Dim Test,result
On Error Resume Next
Set Test=server.createobject ("ADODB.stream")
Set test=nothing
If Err Then
Dim znum
Randomize Timer
Znum=cint (8999*rnd+1000)
Session ("Safecode") =znum
Result=session ("Safecode")
Else
result= "End If
Response.Write Result
End Sub
%>

The safecode.asp file code is as follows


<%

Dim Objcanvas
Dim Pointx,pointy,pointcolor
Dim itemp
Dim Safecode
Dim R,g,b,cc,kk
Cc=80
Kk=30
Safecode = ""
Session ("Safecode") = ""

bgcolor = "FFFFFF"

R = Mid (bgcolor,1,2)
g = Mid (bgcolor,3,2)
B = Mid (bgcolor,5,2)



R = Dechex (r)
g = Dechex (g)
b = Dechex (b)

Set Objcanvas = new Canvas

Objcanvas.globalcolourtable (0) = RGB (255,255,255) ' White
Objcanvas.globalcolourtable (1) = RGB (0,0,0) ' Black
Objcanvas.globalcolourtable (2) = RGB (255,0,0) ' Red
Objcanvas.globalcolourtable (3) = RGB (0,255,0) ' Green
Objcanvas.globalcolourtable (4) = RGB (0,0,255) ' Blue
Objcanvas.globalcolourtable (5) = RGB (128,0,0)
Objcanvas.globalcolourtable (6) = RGB (0,128,0)
Objcanvas.globalcolourtable (7) = RGB (0,0,128)
Objcanvas.globalcolourtable (8) = RGB (128,128,0)
Objcanvas.globalcolourtable (9) = RGB (0,128,128)
Objcanvas.globalcolourtable (+) = RGB (128,0,128)
Objcanvas.globalcolourtable (one) = RGB (R,G,B)

Objcanvas.backgroundcolourindex = 11

Objcanvas.resize Cc,kk,false


Randomize Timer
Safecode = CInt (8999*rnd+1000)

For itemp = 0 to 30
Randomize Timer
pointx = Int (rnd * cc)
Pointy = Int (rnd * KK)
Pointcolor = Int (rnd * 3) # +2
Objcanvas.foregroundcolourindex = Pointcolor
Objcanvas.line Pointx,pointy,pointx,pointy

Next

Objcanvas.foregroundcolourindex = 1
Objcanvas.line 1,1,cc,1
Objcanvas.line 1,kk,1,1
Objcanvas.line 1,kk,cc,kk
Objcanvas.line Cc,1,cc,kk

Session ("Safecode") = Safecode
Dim Sc,sk
Randomize Timer
sc = CInt (24*rnd)
SK = CInt (11*rnd)
Objcanvas.drawtextwe Sc,sk,safecode
Objcanvas.write

function Dechex (HSTR)

Dim result
Dim i,l

result = 0


L = Len (hstr)

For i = l-1 to 0 step-1

result = result + (^ i) *getdecbit (Mid (hstr,i+1,1))

Next

Dechex = result

End Function

function Getdecbit (HSTR)

Dim result
Dim R (16)
Dim i

result = 0

R (0) = "0"
R (1) = "1"
R (2) = "2"
R (3) = "3"
R (4) = "4"
R (5) = "5"
R (6) = "6"
R (7) = "7"
R (8) = "8"
R (9) = "9"
R (Ten) = "a"
R (one) = "B"
R (A) = "C"
R (+) = "D"
R (d) = "E"
R (m) = "F"

For i = 0 to 15

If Hstr=r (i) then result = I:exit for

Next

Getdecbit = result

End Function

%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.