Joke Collection Website - Blessing messages - How to write the website verification code?
How to write the website verification code?
Problem description:
Who tells me how to do verification on the website? Thank you.
Analysis:
Let's first understand the basic idea of verification code from the simplest example.
In the first example, when the form is displayed, a 4-digit random number is generated as the verification code, and the verification code is transmitted through the session. On the data processing page, compare whether the verification code entered by the user is consistent with the value in the process. By the way, I met a confused guy who used hidden input controls to pass the verification code, but I didn't know that reading the page source code exposed the data. And the data in the password input is the same.
& lt%
''''''''**********************************
''''''' * Name: Post *
''''''' * code: ops(op.cc) *
''''' * Usage: verification code example 1: number *
''''''' * Time: July 2005 *
''''''''**********************************
Response. Buffer = true
Fuzzy check code
Response. Write "<& gt& lt text >
''''' = = * * After submitting the form: * = = = = =
If required. Server variables ("request _ method") = "post" and then
Dim founderr,callform,msg
Founderr = false''''' Is there an error?
Callform = false''''' Do you want to call the form?
Msg = ""'''''Prompt information
''''''' = = = = = = = Verification start of verification code = = = = = = = =
Dim session code
sessionCode = session("cCode ")
session("cCode") = " "
CheckCode = trim (request. Form ("ccode"))
If CheckCode = ""then
msg = msg+" & lt; Li> Please fill in the verification code. "
founderr = true
callform = true
else if CSTR(check code)& lt; & gtcstr(sessionCode)
msg = msg+" & lt; Li> verification code is incorrect "
founderr = true
callform = true
If ... it will be over.
''''''' = = = = = = = = = = Verification of verification code is over = = = = = = = = =
If founderr = true, then
Call message ("500")
If callform = true, myform () is called.
other
Msg = "< Li> operation succeeded! "
Call message ("500")
If ... it will be over.
''''''' = = * * Page initialization (before submitting the form) * * * = = = =
other
CheckCode = " "
Call myform ()
If ... it will be over.
Response. Write "& lt/body & gt;; & lt/>
REM subprocess, defining form
Child myform ()
Response. Write "< table width = 500 border =1cellspacing = 0 cellpadding = 5 align = center >" & amp_
“& ltform name = form 1 method = post action = post & gt;” & amp_
“& lttr height = 30 & gt& ltTD rowspan = 2 width = 100 align = center & gt。 Verification Code
“& lttd & gt& ltinput type = text name = ccode size = 10 >& amp_
getc code()& amp; “& lt/TD & gt; & lt/tr >; & amp_
"& lttr height = 30>& lttd & gt Please fill in the verification code on the right side of the text box.
“& lttr height = 30 & gt& lttd colspan=2 align=center >& amp_
"< input type = submission name = submission value = submission > & lt/TD & gt;; & lt/tr >; & amp_
“& lt/form & gt; & lt/table >
End joint
Rem subfunction, generating verification code (four-digit random number)
Function getCCode ()
Dimlannum
Irregular
ranNum = int(9000 * rnd)+ 1000
session("cCode") = ranNum
getCCode = ranNum
End function
Rem prompt information
Sub message (w)
Response. Write "< table width = & ampw & border =1cellspacing = 0cellpadding = 5align = center >" & amp_
"& lttr height = 30>& lttd & gt prompt information.
“& lttr valign=top>。 & lttdclass = "page _ speeder _ 327763530" Color: red; ""> & monosodium glutamate & amp“& lt/TD & gt;; & lt/tr & gt; & lt/table >
End joint
% & gt
The above code shows the general idea of generating verification code. Generating a four-digit random number as a verification code is the simplest and most insecure method.
Maybe you think that each number can correspond to a picture, and you can generate a picture verification code, just like a picture counter. This is not a good idea, it is not essentially different from numerical verification code, and it can't improve security.
Next, how to generate a picture verification code is introduced.
First of all, you can generate a verification code of xbm type through ASP, which is really a picture in xbm format, and you can set the size of the picture at will. For simplicity, let's take numbers as an example.
You can isolate the code that generates the verification code and name it checkcode:
& lt%
''''''''**********************************************
''''''' * Name: check code *
''''''' * code: ops(op.cc) *
''''' * Usage: generate verification code in xbm format *
''''''' * Time: July 2005 *
''''''''**********************************************
Continue to the next step when an error occurs.
dim i
dim countdata
countdata="*********** "
dim rou,ccode,clen
ccode= " "
clen = 4
Irregular
For i= 1 to 4
rou = int(rnd* 10)
ccode = ccode + cstr(rou)
then
Fuzzy structure
strDigits = Array(_
" 0 "、" 0x3c "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x 66 "、" 0x3c "、_
" 1 "、" 0x30 "、" 0x38 "、" 0x30 "、" 0x30 "、" 0x30 "、" 0x30 "、" 0x30 "、" 0x30 "、" 0x30 "、" 0x30 "、" 0x 30 "、" 0x 30 "、_
" 2 "," 0x3c "," 0x66 "," 0x60 "," 0x60 "," 0x30 "," 0x 18 "," 0x0c "," 0x06 "," 0x06 "," 0x7e ",_
" 3 "," 0x3c "," 0x66 "," 0x60 "," 0x60 "," 0x38 "," 0x60 "," 0x60 "," 0x60 "," 0x66 "," 0x3c ",_
" 4 "," 0x30 "," 0x30 "," 0x38 "," 0x38 "," 0x34 "," 0x34 "," 0x32 "," 0x7e "," 0x30 "," 0x78 ",_
" 5 "、" 0x7e "、" 0x06 "、" 0x06 "、" 0x06 "、" 0x3e "、" 0x60 "、" 0x60 "、" 0x60 "、" 0x66 "、" 0x3c "、_
" 6 "," 0x38 "," 0x0c "," 0x06 "," 0x06 "," 0x3e "," 0x66 "," 0x66 "," 0x66 "," 0x66 "," 0x3c ",_
" 7 "," 0x7e "," 0x66 "," 0x60 "," 0x60 "," 0x30 "," 0x30 "," 0x 18 "," 0x 18 "," 0x0c "," 0x0c ",_
" 8 "、" 0x3c "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x3c "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x66 "、" 0x 66 "、" 0x3c "、_
“9”、“0x3c”、“0x66”、“0x66”、“0x66”、“0x66”、“0x7c”、“0x60”、“0x60”、“0x30”、“0x 1c”)
dim iCharWidth,iCharHeight,theBit,theNum,iRow,k,theOffset
Dim image string
imageStr = " "
iCharWidth = 8
iCharHeight= 10* 1
Response. ContentType ="image/x-xbitmap "
Response. Expired =0
Response. Write "# define counter width" & ampicharwidth * clen & amp chr (13) human rights center (10).
Response. Write "# Defining Counter Height" & AmpicharHeight & amp CHR (13) Center for Human Rights (10)
Response. Write "static unsigned character counter_bits[]={"
For iRow=0 to iCharHeight- 1
For i= 1 to clen
theBit=mid(ccode,I, 1)
k=0
do while k & ltubound(strDigits)
If strDigits(k) = theBit, then exit do.
k=k+iCharHeight+ 1
ring
If k & gt=ubound(strDigits), k=0.
Offset = k+1
imageStr = imageStr+(strDigits(the offset+iRow))& amp; ","
then
then
imageStr = left(imageStr,(len(imageStr)- 1))
Response. Write image string
Response. Write "};"
Session ("cCode") = ccode
% & gt
In post, when defining the form, the corresponding code is changed to:
REM subprocess, defining form
Child myform ()
Response. Write "< table width = 500 border =1cellspacing = 0 cellpadding = 5 align = center >" & amp_
“& ltform name = form 1 method = post action = default & gt;” & amp_
“& lttr height = 30 & gt& ltTD rowspan = 2 width = 100 align = center & gt。 Verification Code
“& lttd & gt& ltinput type = text name = ccode size = 10 >& amp_
“& ltimg src = check code width = 32 height = 10 border = 0 & gt; & lt/TD & gt; & lt/tr >; & amp_
"& lttr height = 30>& lttd & gt Please fill in the verification code on the right side of the text box.
“& lttr height = 30 & gt& lttd colspan=2 align=center >& amp_
"< input type = submission name = submission value = submission > & lt/TD & gt;; & lt/tr >; & amp_
“& lt/form & gt; & lt/table >
End joint
The above is the simplest verification code of xbm type. However, users of windows xp sp2 can't see the verification code in this format, because xp sp2 cancels the support for xbm format files. However, this problem can be solved by modifying the registry: open the registry, find HKEY _ local _ machine \ software \ Microsoft \ InterExplorer \ security, right-click to add a dword value, and rename it as BlockXBM, and its value is * * * * * * * *. After the change, just open the browser. You can also use the file editor to edit files containing:
Registry 4
[HKEY _ LOCAL _ MACHINE \ SOFTWARE \ Microsoft \ Inter Explorer \ Security]
" BlockXBM"=dword:*********
Save the file as a registry file with the extension reg, and then double-click the file.
In addition to the verification code in xbm format, we can also use the object of Adodb. To develop a more complex BMP verification code, and we can get the related program from op.cc/downloads/bmpccode.rar.. Using this program, you can generate a verification code that is a mixture of numbers and letters, colors and colored backgrounds.
For friends who rent space, the use of third-party components is greatly restricted. If you have your own server, you can try to use ASP drawing component shotgraph to generate verification code, which is in GIF format and has wide versatility. This component can be obtained from op.cc/downloads/shotgraph.zip., and there are detailed sample programs and documents in the compressed package.
In short, there are many ways to generate verification codes. There are many third-party components that can help you generate verification codes in various styles. Look for it on the internet.
- Related articles
- What if my mother-in-law keeps asking me to cheat my parents of their money?
- What if my husband sends a long message?
- The latest epidemic prevention and control policy of inbound trucks in Jiamusi City in 2022
- Can I still receive text messages after the expiration date?
- China Mobile Express sends short messages.
- Tai' an driver's license subject one test location.
- What should I do if the dial key of Bellevue t708 is gone?
- Unicom SMS prompts that the account is risky.
- What do you mean the service is suspended?
- How to recover Lanzhou Gold Bank after being cheated?