Verification code generation method and device and electronic equipment
By generating verification codes on the server, using the sorting of Chinese characters and pinyin to be selected and verification of background images, the problems of easy cracking and complicated operation of traditional verification codes are solved, achieving higher security and convenience.
Patent Information
- Application Number
- CN202310693476.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-12
- Publication Date
- 2024-12-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional verification codes are easily cracked by hacker programs, with poor security and cumbersome verification operations, which cannot achieve the security and convenience of user verification.
By generating verification codes on the server, randomly sorting the Chinese characters to be selected and their pinyin, generating the target pinyin order, and displaying Chinese characters in the background picture, users are required to select Chinese characters in the target pinyin order for verification, combining the background picture and coordinate sorting, Enhance the security and convenience of verification codes.
Improve the security of verification codes and prevent cracking. At the same time, it simplifies verification operations, improves user experience, and achieves stronger security and convenience.
Smart Images

Figure CN119128862A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of security verification, and in particular to a verification code generation method, device and electronic equipment. Background Art
[0002] With the development of the Internet, spam, fake users, automated programs accessing websites and other illegal behaviors have caused increasing security threats. Verification codes can identify user identities based on user behavior and prevent access and malicious behavior by some automated programs. Currently, there are many types of traditional verification codes, such as traditional text verification codes, digital verification codes (such as verification through mobile phone text messages), sliding verification codes (such as verification through graphics), etc. However, traditional verification codes are easily cracked by black market programs, have poor security, and the verification operation is cumbersome, making it impossible to implement user verification safely and conveniently. Summary of the invention
[0003] The purpose of the present invention is to provide a verification code generation method, device and electronic device, which can make the verification code difficult to be cracked, thereby having stronger security, and the verification operation is relatively convenient, thereby improving the user experience.
[0004] The present invention provides a verification code generation method, which is applied to a server, the server is connected to a client for communication, and the method includes:
[0005] If a verification code acquisition request is received from the client, a first number of Chinese characters to be selected and the pinyin of each Chinese character to be selected are acquired;
[0006] Selecting a second number of candidate Chinese characters from the first number of candidate Chinese characters as verification Chinese characters, and randomly sorting the pinyin of each verification Chinese character to obtain a target pinyin order;
[0007] According to the first number of candidate Chinese characters and the pinyin sequence, a verification code is generated and sent to the client, so that the user can perform verification according to the verification code by selecting each verification Chinese character from the candidate Chinese characters according to the target pinyin sequence.
[0008] Further, the step of generating a verification code and sending it to the client according to the first number of Chinese characters to be selected and the pinyin sequence includes:
[0009] Select the target background image from the preset background image library;
[0010] Display each candidate Chinese character on the target background image to obtain a verification image;
[0011] According to the verification image and pinyin sequence, a verification code is generated and sent to the client.
[0012] Furthermore, before the step of generating a verification code according to the verification image and the target pinyin sequence and sending it to the client, it also includes:
[0013] Get the first coordinate of each verification Chinese character in the verification graph;
[0014] Sort each first coordinate according to the target pinyin order to obtain the target coordinate order;
[0015] Furthermore, the method also includes:
[0016] Obtain the second coordinate and verification pinyin of each selected Chinese character selected by the user from the verification graph;
[0017] According to each second coordinate, each verification pinyin and the selection order of each selected Chinese character selected by the user, a verification coordinate order and a verification pinyin order are obtained;
[0018] Compare the target coordinate order and the verification coordinate order to see if they are consistent, and verify whether the pinyin order is consistent with the target pinyin order;
[0019] If the target coordinate sequence is consistent with the verification coordinate sequence, and the verification pinyin sequence is consistent with the target pinyin sequence, it is determined that the user verification has passed.
[0020] Furthermore, the step of obtaining a first number of Chinese characters to be selected and the pinyin of each Chinese character to be selected includes:
[0021] A first number of Chinese characters to be selected and the pinyin of each Chinese character to be selected are obtained from a preset Chinese character library; wherein the Chinese character library includes a plurality of monosyllabic characters.
[0022] Further, there is at least one interfering Chinese character in the first number of Chinese characters to be selected, and there is no interfering Chinese character's pinyin in the pinyin of the second number of verified Chinese characters.
[0023] The present invention provides a verification code generation device, which is arranged on a server, the server is connected to a client for communication, and the device includes:
[0024] An acquisition module, configured to acquire a first number of Chinese characters to be selected and a pinyin of each Chinese character to be selected if a verification code acquisition request is received from a client;
[0025] A selection module is used to select a second number of candidate Chinese characters from the first number of candidate Chinese characters as verification Chinese characters, and randomly sort the pinyin of each verification Chinese character to obtain a target pinyin order;
[0026] The verification module is used to generate a verification code according to a first number of candidate Chinese characters and a pinyin sequence and send it to a client, so that the user can verify by selecting each verification Chinese character from the candidate Chinese characters according to a target pinyin sequence according to the verification code.
[0027] Furthermore, the verification module is also used to:
[0028] Select the target background image from the preset background image library;
[0029] Display each candidate Chinese character on the target background image to obtain a verification image;
[0030] According to the verification image and pinyin sequence, a verification code is generated and sent to the client.
[0031] An electronic device provided by the present invention includes a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement any one of the verification code generation methods described above.
[0032] The present invention provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement any of the above verification code generation methods.
[0033] The present invention provides a verification code generation method, device and electronic device, the method is applied to a server connected to a client communication, the method comprising: if a verification code acquisition request is received from a client, a second number of to-be-selected Chinese characters are selected from the first number of to-be-selected Chinese characters acquired as verification Chinese characters, and the pinyin of each verification Chinese character is randomly sorted to obtain a target pinyin sequence; according to the first number of to-be-selected Chinese characters and the pinyin sequence, a verification code is generated and sent to the client, so that the user can select each verification Chinese character from the to-be-selected Chinese characters according to the target pinyin sequence for verification according to the verification code. This method randomly sorts the pinyin of each verification Chinese character to obtain the target pinyin sequence, and allows the user to click on the Chinese character according to the target pinyin sequence for user verification, so that the verification code is not easy to be cracked, thereby having stronger security, and the verification operation is relatively convenient, which improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 A flowchart of a verification code generation method provided by an embodiment of the present invention;
[0036] Figure 2 A schematic diagram of the effect of a verification code provided by an embodiment of the present invention;
[0037] Figure 3 A flowchart of another verification code generation method provided by an embodiment of the present invention;
[0038] Figure 4 A schematic diagram of a verification code generation process provided by an embodiment of the present invention;
[0039] Figure 5 A schematic diagram of the structure of a verification code generating device provided by an embodiment of the present invention;
[0040] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] With the development of the Internet, spam, fake users, automated programs accessing websites and other illegal behaviors have caused increasing security threats. In online shopping, registering website accounts and other behaviors, people or programs often maliciously attack or use automated programs to forge operations, causing great trouble to data protection.
[0043] Verification codes can use machine learning models to analyze and learn the characteristics of our online usage behavior, and comprehensively analyze these characteristics to effectively distinguish between human users and automated programs. Therefore, verification codes can identify user identities based on user behavior. In order to prevent access and malicious behavior by some automated programs, verification codes have been widely used on the basis of traditional text, number, and sliding verification codes. At present, there are many types of traditional verification codes, such as traditional text verification code images, digital verification codes (such as verification through mobile phone text messages), sliding verification codes (such as verification through graphics), etc. However, traditional verification codes are easily cracked by black industry programs, have poor security, and the verification operation is cumbersome, and user verification cannot be implemented safely and conveniently.
[0044] Based on this, the embodiments of the present invention provide a verification code generation method, device and electronic device. The technology can be applied to applications that require identification of a verification machine and a real user.
[0045] To facilitate understanding of this embodiment, a verification code generation method disclosed in an embodiment of the present invention is first described in detail. The method is applied to a server, and the server is connected to a client for communication. Figure 1As shown, the method includes:
[0046] Step S102, if a verification code acquisition request is received from the client, obtain a first quantity of candidate Chinese characters and the pinyin of each candidate Chinese character.
[0047] The above-mentioned server refers to a computer system that undertakes service functions in a network system, that is, a computer system responsible for receiving requests from the client, processing these requests, and then generating responses and sending them back to the client. The server can provide services for the client, such as providing resources to the client, saving client data, etc.
[0048] The above-mentioned client, also known as the user side, refers to a program that provides local services for the client corresponding to the server. Except for some applications that only run locally, it can generally be installed on ordinary client computers and needs to cooperate with the server to run.
[0049] Generally speaking, the client can be the computer or mobile phone software we use; the server can be the server that stores web pages and database data.
[0050] The above-mentioned first quantity can be a preset value according to verification requirements. Specifically, the value of the first quantity can be determined by balancing the security needs of the actual application scenario and the user experience. Among them, the larger the value of the first quantity, the higher the security of the verification code. However, at the same time, it is necessary to consider that the operation time of the user cannot be too long. Therefore, generally, the value of the first quantity is usually a positive integer not less than 4 and not greater than 10. For example, the value of the first quantity can be 4, 5, 6, etc.
[0051] In the specific implementation process, the client and the server are in a communication connection. When user verification is required, if the server receives a verification code acquisition request from the client, it can obtain a first quantity of candidate Chinese characters and the pinyin of each candidate Chinese character from a pre-established Chinese character library. Specifically, 4 candidate Chinese characters can be randomly selected from the pre-established Chinese character library, such as "我 (wo)", "要 (yao)", "是 (shi)", "手 (shou)" respectively, and obtain the pinyin "wo" corresponding to "我", the pinyin "yao" corresponding to "要", the pinyin "shi" corresponding to "是", and the pinyin "shou" corresponding to "手".
[0052] Step S104, select a second quantity of candidate Chinese characters from the first quantity of candidate Chinese characters as verification Chinese characters, and randomly sort the pinyin of each verification Chinese character to obtain the target pinyin order.
[0053] The above-mentioned second quantity can be preset in accordance with the balance of security requirements and user experience, or can be randomly determined before generating the verification code each time. Whether it is a preset fixed value or a randomly determined random value, in order to ensure the strength and accuracy of verification, the above-mentioned second quantity of verification Chinese characters is usually not greater than the first quantity - 1, that is, at least one interfering Chinese character is included in the first quantity of candidate Chinese characters obtained. Moreover, since it is necessary to randomly sort the pinyins corresponding to each verification Chinese character in the selected second quantity to obtain the target pinyin order, the number of verification Chinese characters should also be a positive integer not less than 2.
[0054] In the specific implementation process, assuming that the first quantity (for example, 4) of candidate Chinese characters is obtained, the second quantity of candidate Chinese characters can be selected from the 4 candidate Chinese characters as verification Chinese characters. Among them, the second quantity can be 3 (4 - 1 = 3, which is equivalent to including one interfering Chinese character in the first quantity of candidate Chinese characters), or can be 2 (equivalent to including two interfering Chinese characters in the first quantity of candidate Chinese characters).
[0055] For example, 3 candidate Chinese characters (such as "yao", "shi", "shou") can be randomly selected from 4 candidate Chinese characters (such as "wo", "yao", "shi", "shou") as verification Chinese characters, and the pinyins ("yao", "shi", "shou") of each verification Chinese character are randomly sorted to obtain the target pinyin order (such as "shou→yao→shi").
[0056] Optionally, 2 candidate Chinese characters (such as "shi", "shou") can also be randomly selected from 4 candidate Chinese characters (such as "wo", "yao", "shi", "shou") as verification Chinese characters, and the pinyins ("shi", "shou") of each verification Chinese character are randomly sorted to obtain the target pinyin order (such as "shou→shi").
[0057] In actual implementation, the more the number of pinyins of verification Chinese characters in the above-mentioned target pinyin order (equivalent to the larger the value of the second quantity), the higher the security of the verification code. Therefore, generally, the larger value corresponding to the second quantity is usually selected (for example, the second quantity can be 3 and 2, because 3 is greater than 2, and usually 3 is selected) as the number of verification Chinese characters.
[0058] Step S106, generate a verification code according to the first quantity of candidate Chinese characters and the pinyin order, and send it to the client, so that the user can verify by selecting each verification Chinese character from the candidate Chinese characters in accordance with the target pinyin order.
[0059] In the specific implementation process, after determining the target pinyin order, a verification code can be generated according to the first quantity of candidate Chinese characters and the pinyin order in a certain prompt format and sent to the client for further display to the user. For example, as Figure 2 shown Figure 2 Schematic diagram of the effect of a verification code provided by an embodiment of the present invention. Among them, the preset prompt format is: click on the Chinese characters in the figure according to the target pinyin order "", and "shou→yao→shi" in the double quotes is the target pinyin order. The 4 Chinese characters in the figure are the candidate Chinese characters; based on the sent verification code, the user can click on the Chinese characters in sequence according to the target pinyin order from the 4 candidate Chinese characters for verification.
[0060] Still taking Figure 2 as an example, that is, the user can verify by selecting Chinese characters from "wo", "shi", "yao", "shou" according to the target pinyin order "shou→yao→shi". It can be seen that the order of clicking and selecting Chinese characters corresponding to the target pinyin order "shou→yao→shi" is "shou→yao→shi". Specifically, if the verification pinyin order formed by the pinyins corresponding to each selected Chinese character according to the selection order is consistent with the target pinyin order, the verification is successful; otherwise, the verification fails. It can be understood that the figure is only an example implementation method, and does not limit other specific implementation methods of the present solution. For example, the prompt format, the font and size of Chinese characters, the format of Chinese character arrangement, etc.
[0061] The above verification code generation method is applied to a server communicatively connected to a client. The method includes: if a verification code acquisition request from the client is received, select a second quantity of candidate Chinese characters from the acquired first quantity of candidate Chinese characters as verification Chinese characters, and randomly sort the pinyins of each verification Chinese character to obtain a target pinyin order; generate a verification code according to the first quantity of candidate Chinese characters and the pinyin order, and send it to the client, so that the user can verify by selecting each verification Chinese character from the candidate Chinese characters according to the target pinyin order. This method randomly sorts the pinyins of each verification Chinese character to obtain a target pinyin order, allowing the user to click on Chinese characters in the target pinyin order for user verification, which can make the verification code not easily cracked, thus having stronger security, and the verification operation is relatively convenient, improving the user experience.
[0062] An embodiment of the present invention also provides another verification code generation method, which is implemented on the basis of the method in the above embodiment; as Figure 3 shown, the method includes the following steps:
[0063] Step S202, if a verification code acquisition request from the client is received, obtain a first quantity of candidate Chinese characters from a preset Chinese character library, and the pinyin of each candidate Chinese character; among them, the Chinese character library includes multiple single-character Chinese characters.
[0064] The above Chinese character library (which can also be called a word library) can be a publicly known Chinese character library, or a Chinese character library established according to actual verification requirements. This embodiment does not limit it here. For example, in order to improve the general practicability of the verification code, a Chinese character library can be established by counting a certain number of Chinese characters and their corresponding pinyin. Specifically, each Chinese character and its corresponding pinyin can be stored in the Chinese character library one by one to avoid affecting the accuracy of the verification result due to the user not knowing rare Chinese characters or their pinyin.
[0065] In practical applications, the above Chinese character library can be established in advance, and the established Chinese character library can be stored in a database. During each verification process, based on the established Chinese character library, the first quantity of candidate Chinese characters and the pinyin of each candidate Chinese character can be obtained to generate the verification code, without having to establish a Chinese character library every time the verification code needs to be generated, and the candidate Chinese characters and their corresponding pinyin can be quickly obtained, thereby improving the efficiency of generating the verification code. In practical applications, there can be various ways to establish the Chinese character library, as long as the pinyin of each Chinese character can be obtained based on this Chinese character library. For example, by analyzing and counting the pinyin of each Chinese character, a Chinese character library is established.
[0066] Specifically, the set of Chinese characters corresponding to each pinyin can be counted first. Among them, the pinyin of all Chinese characters in the set of Chinese characters corresponding to each pinyin is this pinyin. For example, the Chinese characters corresponding to the pinyin zhi include but are not limited to: zhi, zhi, zhi, zhi; the Chinese characters corresponding to the pinyin shi include but are not limited to: shi, shi, shi, shi.
[0067] In practical applications, there may also be some polyphonic characters. For example, "le" has multiple pronunciations, namely "le" and "yue". Correspondingly, these characters can be removed in advance to obtain a Chinese character library with only multiple single-character pronunciations, thereby avoiding the influence of polyphonic characters on the verification result and improving the accuracy of verification.
[0068] When it is necessary to obtain candidate Chinese characters, multiple (the first quantity) pinyins can be randomly selected first, and then one Chinese character is randomly selected from the set of Chinese characters corresponding to each pinyin among these pinyins, and finally the first quantity of different candidate Chinese characters is obtained. It can be understood that the pinyin of each candidate Chinese character in the first quantity of candidate Chinese characters in this case is different.
[0069] Step S204, select the second quantity of candidate Chinese characters from the first quantity of candidate Chinese characters as verification Chinese characters, and randomly sort the pinyin of each verification Chinese character to obtain the target pinyin order.
[0070] During the specific implementation process, the second number of selected verification Chinese characters can be adjusted. It can be understood that the larger the value of the second number (the maximum is the first number - 1), the more pinyins there are in the target pinyin sequence, and the corresponding generated verification code is more difficult to crack, thereby improving the accuracy and reliability of the verification.
[0071] Step S206, selecting a target background image from a preset background image library.
[0072] In the specific implementation process, a plurality of background images (generally 400*400 images) with low interference and not pure color can be pre-set to form a background image library, and then the background image library can be stored in the database.
[0073] Step S208, display each Chinese character to be selected in the target background image to obtain a verification image.
[0074] In the specific implementation process, after obtaining the first number of Chinese characters to be selected from the Chinese character library, a background image can be randomly selected from the image library, and the background image can be used as a canvas to add each Chinese character to the background image in a preset format. For example, the characters can be pasted on the background image in a 50*50 size ratio without overlapping or going out of the border to generate a verification image. It can be understood that the pattern in the background image can interfere with the cracking program to recognize Chinese characters, thereby increasing the failure rate of cracking the verification code, thereby improving the accuracy and reliability of the verification.
[0075] Step S210, obtaining the first coordinate of each verification Chinese character in the verification graph.
[0076] In the specific implementation process, the coordinates of each candidate Chinese character in the target background image can be cached; then the mapping relationship between the coordinates of each candidate Chinese character in the background image, the candidate Chinese character, and the pinyin corresponding to the candidate Chinese character is stored in the same place in the database, so that they can be queried. In actual implementation, the coordinates of the verification Chinese character (equivalent to the first coordinate of each verification Chinese character in the verification image) can be selected from the cached coordinates of each candidate Chinese character in the target background image.
[0077] Step S212, sorting each first coordinate according to the target pinyin order to obtain the target coordinate order.
[0078] In the specific implementation process, each first coordinate can be sorted according to the target pinyin order according to the mapping relationship between the coordinates of each Chinese character to be selected in the background image, the Chinese character to be selected, and the pinyin corresponding to the Chinese character to be selected, to obtain the target coordinate order. Specifically, assuming that the coordinates of the four Chinese characters to be selected (such as "I", "want", "is", and "hand") added to the target background image are a, b, c, and d respectively; among them, the first coordinates of the three verification Chinese characters (such as "want", "is", and "hand") are b, c, and d respectively, so the above mapping relationship can correspond to "a-I-wo", "b-want-yao", "c-is-shi", and "d-hand-shou"; when each first coordinate is sorted according to the target pinyin order (such as "shou→yao→shi"), the target coordinate order (d→b→c) can be obtained.
[0079] In actual implementation, the target coordinate sequence and the target pinyin sequence can be stored in the database as correct "check points".
[0080] Step S214, generating a verification code according to the verification diagram and the pinyin sequence and sending it to the client.
[0081] During the specific implementation process, after selecting a second number of verification Chinese characters from the first number of candidate Chinese characters and generating the target pinyin sequence, the target pinyin sequence can also be added to the background image according to a preset format (for example, click on the Chinese characters in the image according to the target pinyin sequence) to generate the final verification code.
[0082] Step S216, obtaining the second coordinate and verification pinyin of each selected Chinese character selected by the user from the verification graph.
[0083] In the specific implementation process, the verification code can be returned to the client, wherein the verification code is generally provided with a prompt to click the Chinese characters in the picture according to the target pinyin sequence "". Specifically, it can be to click the Chinese characters in the picture according to the target pinyin sequence "shou→yao→shi".
[0084] When the user receives the verification code and sees the prompt, he can select Chinese characters for verification in the target pinyin order. When the user selects Chinese characters, the client captures the coordinate points of each selected Chinese character in the verification diagram (equivalent to the second coordinates mentioned above), and transmits the coordinate points clicked by the user to the server in the order of clicks. The server can map the relationship to find the pinyin corresponding to each coordinate point (equivalent to the verification pinyin mentioned above).
[0085] Step S218, obtaining a verification coordinate sequence and a verification pinyin sequence according to each second coordinate, each verification pinyin and the selection order of each selected Chinese character selected by the user.
[0086] In the specific implementation process, assume that the user sequentially selects the Chinese characters "要" (yào), "是" (shì), and "手" (shǒu) from the verification graph (equivalent to the selection order of each selected Chinese character by the user being "要 → 是 → 手"). The second coordinates of each selected Chinese character ("要", "是", "手") captured in the verification graph are b, c, and d respectively (equivalent to the verification coordinate order being "b → c → d"). Then, according to the mapping relationship, the verification pinyin "yao", "shi", and "shou" corresponding to each second coordinate can be obtained (equivalent to the verification pinyin order being "yao → shi → shou").
[0087] Step S220: Compare whether the target coordinate order is the same as the verification coordinate order, and whether the verification pinyin order is the same as the target pinyin order.
[0088] Step S222: If the target coordinate order is the same as the verification coordinate order, and the verification pinyin order is the same as the target pinyin order, determine that the user's verification is passed.
[0089] In the specific implementation process, the verification coordinate order and the verification pinyin order can be compared with the correct "verification points" stored in the database. Specifically, the verification coordinate order can be compared with the target coordinate order, and at the same time, the verification pinyin order can be compared with the target coordinate order. If the verification coordinate order is the same as the target coordinate order, and the verification pinyin order is the same as the target coordinate order, the verification is successful; otherwise, the verification fails.
[0090] For a better understanding of the above embodiments, the following can be used Figure 4 A schematic diagram of the verification code generation process provided by the embodiment of the present invention as shown below is used to illustrate the above embodiments.
[0091] From Figure 4 it can be seen that the client is communicatively connected to the server. When the server receives a user request for verification code configuration (equivalent to a verification code acquisition request) sent by the client, it can randomly select 4 combinations from the word library (each combination includes a single Chinese character and the pinyin corresponding to the single Chinese character), select 3 combinations from the 4 selected combinations, and randomly generate a target pinyin order.
[0092] The 4 combinations (equivalent to the first quantity of candidate Chinese characters and the pinyin of each candidate Chinese character) are pasted onto the background image according to a size ratio of 50 * 50 without overlapping and without going out of bounds. The coordinate points corresponding to the 3 selected combinations (equivalent to the first coordinates) are obtained, and they are sorted according to the target pinyin order to obtain the target coordinate order. The target pinyin order and the target coordinate order are used as verification points and stored in the database together. The expiration time can be set to 1 minute.
[0093] The pasted background image (equivalent to the verification image) and the randomly generated target pinyin sequence form a verification code and are returned to the client together. The verification code may include a prompt: Please click on the Chinese characters in the image in the target pinyin sequence "". When the user clicks on the Chinese characters, the client captures the user's click behavior, records the coordinate points (equivalent to the second coordinates), and sends the coordinate points and the click sequence of the coordinate points (equivalent to the verification coordinate sequence) to the server. After receiving the coordinate points, the server immediately queries the pinyin corresponding to the coordinate points through the coordinate points, and obtains the verification pinyin sequence based on the click sequence of the coordinate points. The click sequence of the coordinate points and the verification pinyin sequence are then compared with the check points. If the comparison is successful, the verification is returned to the client; if the comparison fails, the verification failure is returned to the client.
[0094] The verification code generation method provided in the above embodiment includes: obtaining a first number of Chinese characters to be selected and the pinyin of each Chinese character to be selected from a preset Chinese character library; wherein the Chinese character library includes multiple monophonic characters. This method uses pinyin as an index, counts the Chinese character sets corresponding to each pinyin, and clarifies polyphonic characters to establish a Chinese character library, so that the Chinese characters to be selected can be selected from the Chinese character library more quickly and accurately, thereby improving the efficiency and accuracy of verification code generation.
[0095] Furthermore, the method also includes: adding the candidate Chinese characters and the target pinyin sequence selected from the Chinese character library to the background image. This method combined with the pattern in the background image can interfere with the cracking program to recognize these Chinese characters, thereby increasing the failure rate of cracking the verification code, and then improving the accuracy and reliability of the verification.
[0096] Furthermore, the method also includes obtaining the second coordinate and verification pinyin of each selected Chinese character selected by the user from the verification graph; obtaining the verification coordinate sequence and verification pinyin sequence according to each second coordinate, each verification pinyin and the selection order of each selected Chinese character selected by the user; comparing whether the target coordinate sequence and the verification coordinate sequence are consistent, and whether the verification pinyin sequence is consistent with the target pinyin sequence; if the target coordinate sequence and the verification coordinate sequence are consistent, and the verification pinyin sequence is consistent with the target pinyin sequence, it is determined that the user verification has passed. This method allows the user to select Chinese characters according to the target pinyin sequence, and then performs verification according to the verification coordinate sequence and verification pinyin sequence obtained by the user's selection behavior, so that the verification code is not easy to be cracked, thereby having stronger security, and the verification operation is relatively convenient, which improves the user experience.
[0097] The embodiment of the present invention also provides a verification code generating device, which is arranged at a server end, and the server end is connected to a client end for communication, such as Figure 5As shown, the device includes: an acquisition module 50, which is used to obtain a first number of candidate Chinese characters and the pinyin of each candidate Chinese character if a verification code acquisition request is received from a client; a selection module 51, which is used to select a second number of candidate Chinese characters from the first number of candidate Chinese characters as verification Chinese characters, and randomly sort the pinyin of each verification Chinese character to obtain a target pinyin sequence; a verification module 52, which is used to generate a verification code based on the first number of candidate Chinese characters and the pinyin sequence and send it to the client, so that the user can verify by selecting each verification Chinese character from the candidate Chinese characters according to the target pinyin sequence according to the verification code.
[0098] The verification code generating device is arranged at a server end connected to the client end in communication, and the device comprises: if a verification code acquisition request is received from the client end, a second number of Chinese characters to be selected are selected from the first number of Chinese characters to be selected as verification Chinese characters, and the pinyin of each verification Chinese character is randomly sorted to obtain a target pinyin order; according to the first number of Chinese characters to be selected and the pinyin order, a verification code is generated and sent to the client end, so that the user can select each verification Chinese character from the Chinese characters to be selected according to the target pinyin order for verification according to the verification code. The device randomly sorts the pinyin of each verification Chinese character to obtain the target pinyin order, and allows the user to click on the Chinese character according to the target pinyin order for user verification, so that the verification code is not easy to be cracked, thereby having stronger security, and the verification operation is relatively convenient, which improves the user experience.
[0099] Furthermore, the verification module 52 is also used for:
[0100] Select the target background image from the preset background image library;
[0101] Display each candidate Chinese character on the target background image to obtain a verification image;
[0102] According to the verification image and pinyin sequence, a verification code is generated and sent to the client.
[0103] Furthermore, the verification module 52 is also used for:
[0104] Get the first coordinate of each verification Chinese character in the verification graph;
[0105] Sort each first coordinate according to the target pinyin order to obtain the target coordinate order;
[0106] Furthermore, the device also includes:
[0107] Obtain the second coordinate and verification pinyin of each selected Chinese character selected by the user from the verification graph;
[0108] According to each second coordinate, each verification pinyin and the selection order of each selected Chinese character selected by the user, a verification coordinate order and a verification pinyin order are obtained;
[0109] Compare the target coordinate order and the verification coordinate order to see if they are consistent, and verify whether the pinyin order is consistent with the target pinyin order;
[0110] If the target coordinate sequence is consistent with the verification coordinate sequence, and the verification pinyin sequence is consistent with the target pinyin sequence, it is determined that the user verification has passed.
[0111] Furthermore, the acquisition module is also used to:
[0112] A first number of Chinese characters to be selected and the pinyin of each Chinese character to be selected are obtained from a preset Chinese character library; wherein the Chinese character library includes a plurality of monosyllabic characters.
[0113] Further, there is at least one interfering Chinese character in the first number of Chinese characters to be selected, and there is no interfering Chinese character's pinyin in the pinyin of the second number of verified Chinese characters.
[0114] The verification code generation device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned verification code generation method embodiment. For the embodiment of the verification code generation device, reference may be made to the corresponding contents in the aforementioned verification code generation method embodiment.
[0115] The embodiment of the present invention further provides an electronic device, see Figure 6 As shown, the electronic device includes a processor 130 and a memory 131 , wherein the memory 131 stores machine executable instructions that can be executed by the processor 130 , and the processor 130 executes the machine executable instructions to implement the above verification code generation method.
[0116] Further, Figure 6 The electronic device shown further includes a bus 132 and a communication interface 133 , and the processor 130 , the communication interface 133 and the memory 131 are connected via the bus 132 .
[0117] The memory 131 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 133 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 132 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0118] The processor 130 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 130. The above processor 130 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 131, and the processor 130 reads the information in the memory 131 and completes the steps of the method of the above embodiment in combination with its hardware.
[0119] An embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned verification code generation method. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0120] The verification code generation method, device and electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method described in the previous method embodiments. The specific implementation can be found in the method embodiments and will not be repeated here.
[0121] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0122] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A verification code generation method, characterized in that: The method is applied to a server, the server is connected to a client for communication, and the method includes: If a verification code acquisition request is received from the client, a first number of Chinese characters to be selected and a pinyin of each of the Chinese characters to be selected are acquired; Selecting a second number of candidate Chinese characters from the first number of candidate Chinese characters as verification Chinese characters, and randomly sorting the pinyin of each of the verification Chinese characters to obtain a target pinyin order; A verification code is generated based on the first number of the candidate Chinese characters and the pinyin sequence and sent to the client, so that the user can perform verification based on the verification code by selecting each verification Chinese character from the candidate Chinese characters according to the target pinyin sequence.
2. The method according to claim 1, characterized in that The step of generating a verification code according to the first number of the Chinese characters to be selected and the pinyin sequence and sending the verification code to the client comprises: Select the target background image from the preset background image library; Displaying each of the Chinese characters to be selected in the target background image to obtain a verification image; According to the verification diagram and the pinyin sequence, a verification code is generated and sent to the client.
3. The method according to claim 2, characterized in that Before the step of generating a verification code according to the verification graph and the target pinyin sequence and sending the verification code to the client, the method further includes: Obtain the first coordinate of each verification Chinese character in the verification graph; Each of the first coordinates is sorted according to the target pinyin order to obtain a target coordinate order.
4. The method according to claim 3, characterized in that: The method further comprises: Obtaining the second coordinate and verification pinyin of each selected Chinese character selected by the user from the verification graph in the verification graph; According to each of the second coordinates, each verification pinyin and the selection order of each selected Chinese character selected by the user, a verification coordinate order and a verification pinyin order are obtained; Comparing whether the target coordinate sequence is consistent with the verification coordinate sequence, and whether the verification pinyin sequence is consistent with the target pinyin sequence; If the target coordinate sequence is consistent with the verification coordinate sequence, and the verification pinyin sequence is consistent with the target pinyin sequence, it is determined that the user verification is passed.
5. The method according to claim 1, characterized in that The step of obtaining a first number of Chinese characters to be selected and the pinyin of each of the Chinese characters to be selected comprises: A first number of Chinese characters to be selected and the pinyin of each of the Chinese characters to be selected are obtained from a preset Chinese character library; wherein the Chinese character library includes a plurality of monophonic characters.
6. The method according to claim 1, characterized in that There is at least one interfering Chinese character in the first number of the to-be-selected Chinese characters, and there is no pinyin of the interfering Chinese character in the pinyin of the second number of the verified Chinese characters.
7. A verification code generating device, characterized in that: The device is arranged at a server end, the server end is connected to a client end for communication, and the device comprises: An acquisition module, configured to acquire a first number of Chinese characters to be selected and a pinyin of each of the Chinese characters to be selected if a verification code acquisition request is received from the client; A selection module, used for selecting a second number of candidate Chinese characters from the first number of candidate Chinese characters as verification Chinese characters, and randomly sorting the pinyin of each of the verification Chinese characters to obtain a target pinyin order; The verification module is used to generate a verification code based on the first number of the candidate Chinese characters and the pinyin sequence and send it to the client, so that the user can verify by selecting each verification Chinese character from the candidate Chinese characters according to the target pinyin sequence based on the verification code.
8. The device according to claim 7, characterized in that The verification module is further used for: Select the target background image from the preset background image library; Displaying each of the Chinese characters to be selected in the target background image to obtain a verification image; According to the verification diagram and the pinyin sequence, a verification code is generated and sent to the client.
9. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the verification code generation method according to any one of claims 1 to 6.
10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the verification code generation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Input validation method and device
CN103701600A
Verification technique and system for clicking graphic verification code
CN107563181A
Verification code request processing method and device as well as verification code processing system
CN107846412A
Method and apparatus for input verification
US20150186662A1
