Disclosure of Invention
The technical problem to be solved by the invention is to provide a method and a system for generating a picture verification code aiming at the defect that the verification code in the prior art is unsafe, increase the difficulty of identifying picture characters of the verification code by a machine, simultaneously increase the difficulty of using such cracking methods as identifying all verification code pictures by manual exhaustion and matching the result of manual identification according to picture characteristics, improve the safety of a network service system, reduce the difficulty of identifying the verification code and improve user experience.
The technical scheme adopted by the invention for solving the technical problems is as follows:
the method for generating the picture verification code comprises the following steps:
A. acquiring verification code request information, and executing the step B;
B. randomly calling a character string, randomly marking one or more characters in the character string, and then executing the step C;
C. d, storing the marked character or characters as a to-be-verified session for comparison with a verification code input by a user, and then executing the step D;
D. and generating and displaying a verification code picture by the marked character string, and prompting a user to input one or more marked characters in the verification code picture.
In the method for generating the picture verification code, the marking method in the step B is to change the color, the font size, the font background or the font type of the font in the character string, or to add an identification symbol to the character in the character string.
In the method for generating the picture verification code, step B is to randomly select one or more marking methods from a plurality of marking methods to mark one or more characters in the character string.
In the method for generating the picture identifying code, one marked character or a plurality of marked characters is stored according to a certain rule in the step C.
In the method for generating the picture verification code, the character string in the step B is a meaningful short sentence.
The invention also constructs a system for generating the picture verification code, which comprises the following steps:
the verification code request information acquisition unit is used for acquiring verification code request information of a user;
a character string obtaining unit for obtaining a character string at random according to the request information of the verification code request information obtaining unit;
the marking unit is used for randomly selecting one or more marking methods to mark one or more characters in the character string;
the verification code picture generating unit is used for generating a verification code picture containing the character string of one or more marked characters;
the to-be-verified session generating unit is used for generating a to-be-verified session according to all marked characters in the character string;
an input method generation unit for generating an input method for prompting a user to input one or more characters marked in the verification code picture;
the display unit is used for displaying the verification code picture and the input method;
and the storage unit is used for storing the character string, the marking method, the verification code picture and the session to be verified.
In the picture verification code generation system of the present invention, the marking method includes changing a color, a font size, a font background, or a font type of a font in the character string, or otherwise adding an identification symbol to a character in the character string.
In the picture verification code generation system of the present invention, the to-be-verified session generation unit generates the to-be-verified session from all the marked characters in the character string according to a certain rule.
In the picture authentication code generation system of the present invention, the character string stored in the storage unit is a meaningful phrase.
In the picture verification code generation system of the invention, the input method is displayed in a text form alone or together with the verification code in a picture form.
The invention has the following beneficial effects: by randomly marking one or more characters in the character string, the number of changes of the verification code is increased, and the probability of the same verification code is reduced; the user inputs one or more marked characters according to the prompt of the input method, so that the difficulty of identifying the characters of the verification code picture by a machine is greatly increased, the difficulty of using such cracking methods as identifying all verification code pictures by manual exhaustion and matching the results of manual identification according to picture characteristics is also greatly increased, and the safety of the network service system is greatly improved.
Detailed Description
As shown in fig. 1, the method for generating a picture verification code according to a preferred embodiment of the present invention includes the following steps:
s101, acquiring verification code request information, and executing the step S102;
s102, randomly calling a character string, randomly marking one or more characters in the character string, and then executing the step S103;
s103, storing the marked character or characters as a to-be-verified session for comparison with a verification code input by a user, and then executing the step S104;
s104, generating and displaying a verification code picture by the marked character string, and executing the step S105;
and S105, prompting the user to input one or more marked characters in the verification code picture.
Further, in the method for generating the image verification code according to the preferred embodiment of the present invention, in step S102, the marking method is to change the color, the font size, the font background, or the font type of the font in the character string, or to add an identifier to the characters in the character string. The marking method can also be used for marking by characters, lines, points, fonts and the like, more complicated points can be marked by graphs and patterns, the graphs and the patterns which are slightly complicated greatly increase the difficulty of automatic program identification, and the characters which are not marked are interfered. In general, there are many methods of marking, as long as the user can easily recognize the marked characters.
For example, a string of 10 characters, from which 210 combinations of four characters are randomly identified, and 210 × S variations, if any, for example, for a user to enter a character in a color font, for a user to enter italics, or for a user to enter a character identified in a pattern.
Assuming that the length of the character string used for generating the verification code picture is M, only one marking method is used, the number of marked characters is N (1 ≦ N ≦ M), the types of the marking methods are S, the number of times of verification code changes is T, then,
<math><mrow><mi>T</mi><mo>=</mo><munderover><mi>Σ</mi><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>N</mi></munderover><msubsup><mi>C</mi><mi>M</mi><mi>N</mi></msubsup><mo>*</mo><mi>S</mi></mrow></math>
if one short sentence of the identifying code has 10 characters, 1 to 4 characters are randomly selected from the short sentence, and the marking method in 10 is used, the total change times is 3850, the website only needs 3 short sentences to exceed the change effect of the current common 4-digit identifying code (the change times of 4 digits is 10000), if 1 to 5 characters are randomly selected, the change is 6370, if 1 to 5 characters are randomly selected from 20 characters, the total change number is nearly 22 ten thousand, the change number of 3 short sentences of the identifying code with the length of 20 can exceed the change of the 4-digit identifying code consisting of 62 upper and lower case letters and digits randomly, the former only needs the user to input the marked part of the characters, the marking method of the identifying code seen by the user each time is randomly changed, and the number of the characters marked part is also randomly changed within a certain range, the user is required to input 4 italic characters, the next time, the characters may be 3 red characters, and the user can be asked to input the characters marked by the apple by using a complex pattern such as a pattern shaped like an apple, so that the cracking difficulty of the picture verification code is greatly increased.
Further, in the method for generating the image verification code according to the preferred embodiment of the present invention, in step S102, one marking method may be randomly selected from a plurality of marking methods to mark one or more characters in the character string, or two or more marking methods may be used to mark characters in the character string, for example, the size of a part of the font in the character string is changed, and the background color of a part of the font is changed. Generally, only one marking method is used, so that a user can recognize the characters more easily, the number of the characters input by the user can be reduced, and the verification is quicker.
Further, in the method for generating the image verification code according to the preferred embodiment of the present invention, in step S103, the marked character or characters are stored according to a certain rule, for example, the marked character or characters are stored according to a sequence from front to back of the marked character or characters in the character string, or the marked character or characters are stored according to a sequence from back to front of the marked character or characters in the character string, or the marked character or characters in the character string are stored in any sequence, as long as all the marked characters in the stored character string are stored. Therefore, the number of the identified characters can be less than or equal to the number of the characters of the character string in the picture verification code, and can also be greater than the number of the characters of the character string in the picture verification code. However, only one identification method is generally used to mark the character string, so the number of the identified characters is generally less than or equal to the number of the characters of the character string in the picture verification code. However, this requires prompting the user to input the corresponding input method of the verification code, so as to ensure that the program can quickly and correctly determine whether the verification code input by the user matches with the content in the session to be verified, thereby enabling the user to pass the verification or re-input a new verification code.
Further, in the method for generating the picture verification code according to the preferred embodiment of the present invention, the character string in step S102 is a meaningful phrase. The invention only needs the user to input partial characters in the verification code picture, and the characters are randomly identified by the program, so the characters used for generating the verification code picture can be a meaningful short sentence instead of random character combinations, and the website can generate the verification code by using short sentences like blessings, thereby improving the user experience. Therefore, the user can easily understand the content displayed on the picture verification code, and the user can conveniently input the verification code. Meanwhile, interference elements such as lines and points in the prior art are not added in the picture verification code, so that a user can recognize the verification code more conveniently.
In step S105, a sentence prompting the user to input the marked one or more characters in the picture of the verification code is generated and displayed, and the user inputs the identified one or more characters in the picture verification code according to the sentence. The prompt is displayed on an interface operated by a user in a text mode or is displayed together with a verification code picture in a picture mode.
As shown in fig. 2, the preferred embodiment of the present invention further constructs a system for generating a picture verification code according to the method for generating a picture verification code, which includes a verification code request information obtaining unit 100, a character string obtaining unit 300, a marking unit 200, a verification code picture generating unit 400, a to-be-verified session generating unit 201, an input method generating unit 202, a storage unit 500, and a display unit 600. Wherein,
an authentication code request information obtaining unit 100 for obtaining authentication code request information of a user;
a character string obtaining unit 300 configured to randomly obtain a character string according to the request information of the verification code request information obtaining unit;
a marking unit 200 for randomly selecting one or more marking methods to mark one or more characters in the character string; there are many ways of marking, as long as the user can easily and quickly recognize the identified character in the character string.
A captcha picture generating unit 400 for generating a captcha picture containing a character string of one or more marked characters; the authentication code picture is displayed on the user operation interface through the display unit 600, and the authentication code is input according to the marked characters in the authentication code picture.
A to-be-verified session generating unit 201, configured to generate a to-be-verified session according to all marked characters in the character string; the session to be verified is stored in the storage unit 500, when the user inputs the verification code information, the program automatically calls the session to be verified as a basis for judging whether the verification code input by the user is correct, when the verification code input by the user is the same as the content in the session to be verified, the user passes the verification, otherwise, a new verification code needs to be input again.
An input method generation unit 202 for generating an input method for prompting a user to input one or more characters marked in the verification code picture; the input method and the marking method in the marking unit 200 are actually in one-to-one correspondence, and if the marking unit 200 randomly amplifies one or more characters in the character string, the input method is to prompt the user to input larger characters in the verification code picture; for another example, if the marking unit 200 randomly marks one or more characters in the character string as red, the input method is to prompt the user to input the red characters in the verification code picture; for another example, if the marking unit 200 marks an apple symbol above one or more characters in the character string at random, the input method is to prompt the user to input the characters marked with the apple symbol in the verification code picture.
The display unit 600 is used for displaying the verification code picture and an input method, and the input method is displayed on the user operation interface in a picture or text mode.
The storage unit 500 is used for storing the character string, the marking method and the session to be verified.
Further, in the picture authentication code generation system according to the preferred embodiment of the present invention, the randomly selected marking method from the storage unit 500 includes changing the color, the font size, the font background, or the font type of the font in the character string, or additionally adding an identification symbol to the characters in the character string. The marking method can also be used for marking by characters, lines, points, fonts and the like, more complicated points can be marked by graphs and patterns, the graphs and the patterns which are slightly complicated greatly increase the difficulty of automatic program identification, and the characters which are not marked are interfered. In general, there are many methods of marking, as long as the user can easily recognize the marked characters. Two or more marking methods can also be used simultaneously to mark the characters in the character string, such as changing the size of a part of the fonts in the character string and changing the background color of a part of the fonts. Generally, only one marking method is used, so that the user can recognize the characters more easily, the number of the characters input by the client can be reduced, and the verification is quicker.
The invention has the great advantage that even if the character strings called each time are the same, the marking method called each time is the same, but the verification codes input by the user are different because of different characters or the number of the characters marked randomly, so that the machine of the verification codes can not correctly input the verification codes through a prior program or a good image processing function, the verification can not be passed, and the safety of the network service system is greatly improved.
Furthermore, in the preferred embodiment of the present invention, in the image verification code generation system, the to-be-verified session generation unit generates to-be-verified sessions from all marked characters in the character string according to a certain rule. For example, the marked character or characters in the character string are stored from front to back, or the marked character or characters in the character string are stored from back to front, or the marked character or characters in the character string are stored in any order, as long as all the marked characters in the stored character string are stored. However, this requires prompting the user to input the corresponding input method of the verification code, so as to ensure that the program can quickly and correctly determine whether the verification code input by the user matches with the content in the session to be verified, thereby enabling the user to pass the verification or re-input a new verification code.
Further, in the preferred embodiment of the present invention, in the picture verification code generation system, the character string stored in the storage unit 500 is a meaningful phrase. The invention only needs the user to input partial characters in the verification code picture, and the characters are randomly identified by the program, so the characters used for generating the verification code picture can be a meaningful short sentence instead of random character combinations, and the website can generate the verification code by using short sentences like blessings, thereby improving the user experience. Therefore, the user can easily understand the content displayed on the picture verification code, and the user can conveniently input the verification code. Meanwhile, interference elements such as lines and points in the prior art are not added in the picture verification code, so that a user can recognize the verification code more conveniently.
Further, in the picture authentication code generation system according to the preferred embodiment of the present invention, the input method for prompting the user to input the one or more characters marked in the authentication code picture is displayed on the user operation interface in the form of text alone or together with the authentication code in the form of picture. Of course, the display may be in other manners as long as the user knows how to input the marked character or characters in the verification code picture.
The picture identifying code provided by the invention is additionally provided with an input method in the process of inputting the identifying code by a user, and the input method is displayed in a text or picture mode, so that a robot program needs to crack the identifying code, not only the characters in the picture of the identifying code but also the input method of the identifying code, and thus the cracking difficulty of the program on the identifying code is greatly improved. Step one, even if the program identifies the characters in the verification code picture and the verification code input method, the verification can be passed only by identifying and inputting the corresponding characters according to the input method by a higher-level artificial intelligence, so that the safety of the network service system is greatly improved;
the marking method is corresponding to the input method, the marking method has a plurality of methods, even if the selected character strings are the same, the marking results are also different greatly, the number of the change of the verification code required to be input by the user is greatly increased, the probability of inputting the same verification code is reduced, the possibility that the robot program passes the verification is greatly reduced, and the safety of the network is greatly improved.
In addition, interference factors interfering machine identification do not need to be added into the verification code picture, so that the difficulty of user identification is reduced, and the user experience is improved; the characters on the verification code picture can be a meaningful short sentence, and the website can use a plurality of blessing short sentences or a plurality of advertising words to generate the verification code according to specific conditions, so that the user feels more friendly and humanized, and the user experience is improved.
It will be understood that modifications and variations can be made by persons skilled in the art in light of the above teachings and all such modifications and variations are intended to be included within the scope of the invention as defined in the appended claims.