CN103971315A - Method for generating image verification codes - Google Patents

Method for generating image verification codes Download PDF

Info

Publication number
CN103971315A
CN103971315A CN201310035137.6A CN201310035137A CN103971315A CN 103971315 A CN103971315 A CN 103971315A CN 201310035137 A CN201310035137 A CN 201310035137A CN 103971315 A CN103971315 A CN 103971315A
Authority
CN
China
Prior art keywords
image
character string
length
checkcode
picture
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201310035137.6A
Other languages
Chinese (zh)
Inventor
陈耀
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu Zhong Tongyang Software Service Co Ltd
Original Assignee
Jiangsu Zhong Tongyang Software Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangsu Zhong Tongyang Software Service Co Ltd filed Critical Jiangsu Zhong Tongyang Software Service Co Ltd
Priority to CN201310035137.6A priority Critical patent/CN103971315A/en
Publication of CN103971315A publication Critical patent/CN103971315A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a method for generating image verification codes, and relates to the technical field of network application. The method includes the steps that characters are preset, wherein characters to be displayed on a canvas are self-defined in an array vitrine; a character string checkcode is generated, wherein a user requests to generate the verification codes, the length of the verification codes needing inputting is set, a system generates random numbers by calling rnd. Next (vitrine. Length-1), according to the generated random numbers, corresponding characters are found in the self-defined array vitrine, and the process of randomly generating random numbers is repeated until the number of the generated random numbers meets the length of the verification codes, needing inputting, set by the user; a blank image is created, wherein the size of a current font is set as fontsize, according to the fontsize and the length of the drawn character string, the blank image is created, Image=newBitmap ((int)Math,Ceiling (checkcode. Length * fontsize), 22), and an object Graphicsgr=Graphics. FromImage (Image) is generated according to the Image; the character string checkcode is drawn, wherein the character string is drawn by calling a gr. DrawStringde method; the verification codes are output, wherein the drawn character string checkcode is stored in Session, and the image is output on a webpage in a stream mode, Image. Save (Response. OutputStream, System. Drawing. Imaging. ImageFormat. Gif).

Description

A kind of generation method of picture validation code
Technical field
The present invention relates to network application technical field, be specifically related to a kind of generation method of picture validation code.
Background technology
Day by day universal along with computing machine and computer network, internet has been deep into the every field of people's work, studying and living.In current information and network times, it is more and more important that information security shows, in order to prevent that some unique user from utilizing robot (rogue program) auto registration, login automatically, malice to pour water and malice increases database access, with specific program Brute Force password, can adopt verification code technology.Current most of network information system has the function of picture validation code.A kind of method that this programme provides simple and fast to generate graphical verification code, and added the term of validity that checking generates.
Summary of the invention
The present invention proposes a kind of method of simple and fast generation graphical verification code, comprises the following steps:
Preset characters step, will be on painting canvas character to display self-defined in array vitrine;
The generation step of character string checkcode, user asks to generate identifying code, and the length l ength of identifying code that requires input is set, system produces random number by calling rnd.Next (vitrine.Length-1), in self-defined array vitrine, find out corresponding character according to produced random number, repeat above-mentioned random generation random number process, until the number of generation random number is satisfied with user, the length l ength that requires the identifying code of inputting is set;
Create blank image step, the size that current font is set is fontsize, create the blank image of a width according to the size of font with the length of drawn character string, Image=new Bitmap ((int) Math.Ceiling (checkcode.Length * fontsize), 22), according to a raw Graphics gr=Graphics.FromImage (Image) object of Image;
Draw character string checkcode step, call the method for gr.DrawStringde and draw character string;
The output step of identifying code, above-mentioned drawn character string checkconde is kept in Session, by picture with stream formal output to webpage, Image.Save (Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif).
After drawing the step of character string checkcode, comprise picture sheet interfering line step, create Random object rnd1, call method rnd1.Next (Image.Width) produces respectively two some x, y with rnd1.Next (Image.Heigth) at every turn.
After described picture sheet interfering line step, also comprise and add noise spot step, the method for calling image.SetPixel () produces random point, according to random point, noise spot is set.
After adding noise spot step, also comprise picture sheet frame step, call the method picture sheet frame of gr.DrawRectangle.
After the output step of identifying code, also comprise countdown step, in the time that picture outputs on webpage, start countdown, in the effective time of display end dynamic reminding user rs authentication code, in the time that countdown is 0, prompting user rs authentication code lost efficacy, and regenerated identifying code.
The generation method of a kind of picture validation code of the present invention's invention, realizes simple cost low, does not need other assemblies, technology maturation, and operating rate is high, has very high use value.
Brief description of the drawings
Fig. 1 is the generation method schematic diagram of a kind of picture validation code of inventing of the present invention.
Fig. 2 is the preferred schematic diagram of generation method of a kind of picture validation code of inventing of the present invention.
Embodiment
The generation method of a kind of picture validation code of the present invention's invention, its schematic diagram as shown in Figure 1, comprises the following steps,
Preset characters step, will be on painting canvas character to display self-defined in array vitrine;
User asks to generate identifying code, and the length l ength of the identifying code that requires input is set;
Create blank image step, the size that current font is set is fontsize, create the blank image of a width according to the size of font with the length of drawn character string, Image=new Bitmap ((int) Math.Ceiling (checkcode.Length * fontsize), 22), according to a raw Graphics gr=Graphics.FromImage (Image) object of Image;
System produces random number by calling rnd.Next (vitrine.Length-1), finds out corresponding character according to produced random number in self-defined array vitrine;
Draw character string checkcode step, call the method for gr.DrawStringde and draw character string;
Repeat above-mentioned random generation random number process, until the number of generation random number is satisfied with user, the length l ength that requires the identifying code of inputting is set;
The output step of identifying code, above-mentioned drawn character string checkconde is kept in Session, by picture with stream formal output to webpage, Image.Save (Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif).
The generation method of a kind of picture validation code of the present invention's invention, its preferred schematic diagram as shown in Figure 2, comprises the following steps:
Preset characters step, will be on painting canvas character to display self-defined in array vitrine;
User asks to generate identifying code, and the length l ength of the identifying code that requires input is set;
Create blank image step, the size that current font is set is fontsize, create the blank image of a width according to the size of font with the length of drawn character string, Image=new Bitmap ((int) Math.Ceiling (checkcode.Length * fontsize), 22), according to a raw Graphics gr=Graphics.FromImage (Image) object of Image;
System produces random number by calling rnd.Next (vitrine.Length-1), finds out corresponding character according to produced random number in self-defined array vitrine;
Draw character string checkcode step, call the method for gr.DrawStringde and draw character string;
Repeat above-mentioned random generation random number process, until the number of generation random number is satisfied with user, the length l ength that requires the identifying code of inputting is set;
Picture sheet interfering line step, creates Random object rnd1, and call method rnd1.Next (Image.Width) produces respectively two some x, y with rnd1.Next (Image.Heigth) at every turn;
Add noise spot step, the method for calling image.SetPixel () produces random point, according to random point, noise spot is set;
Picture sheet frame step, calls the method picture sheet frame of gr.DrawRectangle;
The output step of identifying code, above-mentioned drawn character string checkconde is kept in Session, by picture with stream formal output to webpage, Image.Save (Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
Countdown step, in the time that picture outputs on webpage, starts countdown, and in the effective time of display end dynamic reminding user rs authentication code, in the time that countdown is 0, prompting user rs authentication code lost efficacy, and regenerated identifying code.

Claims (5)

1. a generation method for picture validation code, is characterized in that, comprises the following steps:
Preset characters step, will be on painting canvas character to display self-defined in array vitrine;
The generation step of character string checkcode, user asks to generate identifying code, and the length l ength of identifying code that requires input is set, system produces random number by calling rnd.Next (vitrine.Length-1), in self-defined array vitrine, find out corresponding character according to produced random number, repeat above-mentioned random generation random number process, until the number of generation random number is satisfied with user, the length l ength that requires the identifying code of inputting is set;
Create blank image step, the size that current font is set is fontsize, create the blank image of a width according to the size of font with the length of drawn character string, Image=new Bitmap ((int) Math.Ceiling (checkcode.Length * fontsize), 22), according to a raw Graphics gr=Graphics.FromImage (Image) object of Image;
Draw character string checkcode step, call the method for gr.DrawStringde and draw character string;
The output step of identifying code, above-mentioned drawn character string checkconde is kept in Session, by picture with stream formal output to webpage, Image.Save (Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif).
2. the generation method of a kind of picture validation code as claimed in claim 1, it is characterized in that, after drawing the step of character string checkcode, comprise picture sheet interfering line step, create Random object rnd1, call method rnd1.Next (Image.Width) produces respectively two some x, y with rnd1.Next (Image.Heigth) at every turn.
3. the generation method of a kind of picture validation code as claimed in claim 2, it is characterized in that, after described picture sheet interfering line step, also comprise and add noise spot step, the method of calling image.SetPixel () produces random point, according to random point, noise spot is set.
4. the generation method of a kind of picture validation code as claimed in claim 3, is characterized in that, after adding noise spot step, also comprises picture sheet frame step, calls the method picture sheet frame of gr.DrawRectangle.
5. the generation method of a kind of picture validation code as claimed in claim 4, it is characterized in that, after the output step of identifying code, also comprise countdown step, in the time that picture outputs on webpage, start countdown, in the effective time of display end dynamic reminding user rs authentication code, in the time that countdown is 0, prompting user rs authentication code lost efficacy, and regenerated identifying code.
CN201310035137.6A 2013-01-30 2013-01-30 Method for generating image verification codes Pending CN103971315A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310035137.6A CN103971315A (en) 2013-01-30 2013-01-30 Method for generating image verification codes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310035137.6A CN103971315A (en) 2013-01-30 2013-01-30 Method for generating image verification codes

Publications (1)

Publication Number Publication Date
CN103971315A true CN103971315A (en) 2014-08-06

Family

ID=51240768

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310035137.6A Pending CN103971315A (en) 2013-01-30 2013-01-30 Method for generating image verification codes

Country Status (1)

Country Link
CN (1) CN103971315A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283884A (en) * 2014-10-13 2015-01-14 宁波公众信息产业有限公司 Verification code verification method
CN105824486A (en) * 2015-01-07 2016-08-03 阿里巴巴集团控股有限公司 Method and apparatus for displaying check codes
CN110808961A (en) * 2019-10-16 2020-02-18 上海易点时空网络有限公司 Data processing method and device for security verification

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283884A (en) * 2014-10-13 2015-01-14 宁波公众信息产业有限公司 Verification code verification method
CN105824486A (en) * 2015-01-07 2016-08-03 阿里巴巴集团控股有限公司 Method and apparatus for displaying check codes
CN105824486B (en) * 2015-01-07 2019-02-05 阿里巴巴集团控股有限公司 A kind of method and device showing check code
CN110808961A (en) * 2019-10-16 2020-02-18 上海易点时空网络有限公司 Data processing method and device for security verification
CN110808961B (en) * 2019-10-16 2022-02-01 上海易点时空网络有限公司 Data processing method and device for security verification

Similar Documents

Publication Publication Date Title
CN103488934B (en) A kind of identifying code input method, Apparatus and system
CN101178813A (en) Method and apparatus for generating photograph identifying code
JP2019535084A (en) Image processing neural networks with separable convolutional layers
US9614837B2 (en) Systems and methods for verifying human interaction with a computer interface
CN105447204A (en) Website recognition method and apparatus
CN103903038A (en) System for dynamically displaying two-dimension codes and implementation method and application thereof
CN104348612A (en) Third-party website login method based on mobile terminal and mobile terminal
CN105592065A (en) Method and system for website registration on the basis of mobile phone message
CN109561059B (en) Account login method and system, terminal and storage medium thereof
CN103886456A (en) Payment system based on dynamic display two-dimension code and implementation method thereof
CN105574398A (en) Verification code verification method and device
CN104348617A (en) Verification code processing method and device, and terminal and server
CN110866239A (en) Verification code request processing method, device, equipment and computer storage medium
CN104702677A (en) Method, device and system for treating link
CN103971315A (en) Method for generating image verification codes
CN104052757A (en) Identity recognition system and method based on client-side application in mobile phone
CN102904893A (en) Verifying device and verifying method
CN105337940A (en) Page verification method, client, server and system
CN109688109B (en) Verification method and device of verification code based on client information identification
CN104079527A (en) Information processing method and electronic equipment
CN111145054A (en) Signing method, device and storage medium for electronic contracts of same type
CN103957104A (en) Dynamic token anti-phishing method and device
CN109960939B (en) Remote HTML5 page loading method and system
CN103795531A (en) Secret key authentication method based on two-dimension code and system thereof
CN115564000A (en) Two-dimensional code generation method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20140806