ASP without components to generate picture verification code with canvas

Source: Internet
Author: User
No Components | verification Code

Click here to download the source

The relevant pictures are as follows:

Dim Objcanvas
Dim Pointx,pointy,pointcolor
Dim itemp
Dim Safecode
Dim R,g,b,cc,kk

Const Camount = 36 ' text quantity
Const ccode = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
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)


    randomize
For i = 0 to 3
  safecode = Safecode & "" & Mid (Ccode, T (RND * camount) + 1, 1)
    next
' miscellaneous point
  
for itemp = 0 to
  ra Ndomize timer
  pointx = Int (Rnd * cc)
  pointy = Int (Rnd * kk)
  pointcolor = int (RND * 3) +2
  objcanvas.foregroundcolourindex = pointcolor  
  objcanvas.line Pointx,pointy,pointx,pointy
  
  next
' border
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
' Text
Randomize timer
sc = CInt (3*rnd)
SK = CInt (3*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.