A method, device, equipment and medium for generating and verifying a picture verification code
By building a sequence library and using the Chinese sequence pinyin length out of order algorithm to generate image verification codes for out of order Chinese short text sequences, the existing verification codes are easily cracked and difficult for users to recognize, achieving higher security and user experience.
Patent Information
- Application Number
- CN202410237660.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-01
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-03-01
AI Technical Summary
The existing verification code technology has problems that are easily cracked by computer programs and difficult for users to identify, resulting in insufficient security and poor user experience.
By summarizing and filtering the positive Chinese short text sequences with sequence length 4, the Chinese sequence pinyin length out of order algorithm is called to disrupt the character order, and the image verification code containing the out of order Chinese short text sequence is generated, and verification is carried out in combination with the sorting prompt information.
It improves the difficulty of cracking verification codes, reduces the error rate when users recognize verification codes, improves user experience, and takes into account the security and usability of verification codes.
Smart Images

Figure CN118171255B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and medium for generating and verifying a picture verification code. Background Art
[0002] With the continuous development of Internet technology and crawler technology, when many online websites or systems with B / S (browser / server mode) architecture receive a large number of abnormal visits, the system may be paralyzed and unable to provide normal services to users. Faced with this situation, the verification technology that only uses usernames and passwords can no longer meet the security requirements of most online websites or systems. The use of verification code authentication technology can effectively solve most abnormal access behaviors and provide a good security barrier for the normal operation of the system. Therefore, adding a link for users to enter verification codes during system registration or login has become a simple and effective way to solve this type of problem.
[0003] At present, most of the common verification codes on the market are completed by combining random numbers, letters, four arithmetic operations, physical pictures or picture slider filling and user click area matching. However, the above types of verification codes have two obvious disadvantages. On the one hand, the non-interactive simple picture verification code system is very easy to be cracked by computer programs, resulting in the invalidation of the verification code. On the other hand, the interactive complex picture verification code system sometimes makes it difficult for real users to effectively identify the picture verification code due to reasons such as object shape, position deviation, and low picture clarity, thereby reducing the user experience. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, equipment and medium for generating and verifying picture verification codes, which can make up for the shortcomings of many current verification methods, take into account the usability and security criteria of verification code design, increase the difficulty of cracking verification codes and reduce the error rate when users identify verification codes, and improve user experience.
[0005] A method for generating and verifying a picture verification code, the method comprising:
[0006] A sequence library is constructed by summarizing and screening the regular Chinese short text sequences with a sequence length of 4, a set number of regular Chinese short text sequences are extracted from the sequence library to form a regular list, and a Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each regular Chinese short text sequence in the regular list, and after obtaining the corresponding scrambled list, each scrambled Chinese short text sequence in the scrambled list is written into the canvas set by the initialization in combination with the sorting prompt information, a corresponding picture verification code is generated, and the regular Chinese short text sequence corresponding to each picture verification code is used as a file name to save the picture verification code, and a picture verification code set is obtained;
[0007] When the user of the client enters the registration or login interface, the client randomly reads a picture verification code from the picture verification code set for display, and encrypts the file name of the picture verification code into a first-class sequence code for identification;
[0008] The string sequence entered by the user after inference and sorting based on the image verification code displayed by the client is obtained from the form submitted by the user, and the length and key consistency verification are performed on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
[0009] In one embodiment, a sequence library is constructed by collecting and screening Chinese short text sequences with a sequence length of 4, including:
[0010] Load the deduplicated Chinese short text sequence dataset; the Chinese short text sequence dataset includes Chinese idiom data, domain term data, and proper noun data;
[0011] By traversing and screening the strait-sequence Chinese short text sequences with a sequence length of 4 in the strait-sequence Chinese short text sequence dataset and storing them, a list-type sequence library is constructed.
[0012] In one embodiment, a set number of normal Chinese short text sequences are extracted from a sequence library to form a normal sequence list, and a Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each normal Chinese short text sequence in the normal sequence list to obtain a corresponding scrambled sequence list, including:
[0013] Extract K Chinese short text sequences in positive order from the sequence library to form a positive order list S k , by traversing the positive sequence list S in sequence k Each Chinese short text sequence in the right order is used, and the Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each Chinese short text sequence in the right order to obtain the corresponding scrambled list S k ’ ; Among them, the positive sequence list S k The Chinese short text sequence and random list S in the positive order k ’ The random Chinese short text sequences in .
[0014] In one embodiment, the specific steps of the Chinese sequence pinyin length scrambling algorithm include:
[0015] Input a Chinese short text sequence Seq1 with a sequence length of 4;
[0016] Create a dictionary dicts to store temporary sorting results;
[0017] Convert each character in the Chinese short text sequence Seq1 into the corresponding standard pinyin format without tone to obtain a pinyin list L;
[0018] Traverse each pinyin in the pinyin list L in turn, use the character corresponding to each pinyin as the key, and use the length of each pinyin as the value to form a key-value pair and store them in the dictionary dicts;
[0019] Sort the keys in the dictionary dicts in ascending or descending order using a dictionary sorting algorithm according to the size of the values in the dictionary dicts, and save the sorting results in the S_List tuple list;
[0020] Initialize an empty string Seq2;
[0021] Loop through the S_List tuple list 4 times, take out the current first key in the S_List tuple list as the character C, and concatenate them using the string concatenation method of Seq2=Seq2+C;
[0022] Return Seq2 until the loop ends to obtain Seq2 with a sequence length of 4; wherein Seq2 with a sequence length of 4 is the disordered Chinese short text sequence corresponding to Seq1.
[0023] In one embodiment, the initialization setting of the canvas includes:
[0024] The size and background color of the canvas and the type, size and color of the font are initialized, and the initial storage location of the sorting prompt information is set to be located in the upper left corner of the canvas; wherein the background color of the canvas is different from the font color, and the colors of different characters in the canvas are different.
[0025] In one embodiment, the file name of the image verification code is encrypted into a first type of sequence code for identification, including:
[0026] The file name of the image verification code is encrypted into a corresponding first-class 32-bit MD5 sequence code according to the MD5 encryption algorithm, and the first-class 32-bit MD5 sequence code is used as a verification key for identification in the client background.
[0027] In one embodiment, a string sequence input by the user after inference and sorting based on the image verification code displayed by the client is obtained from the form submitted by the user, and the length verification and key consistency verification are performed on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect, and a new round of verification is started, including:
[0028] Obtain the string sequence entered by the user after inference and sorting based on the image verification code displayed by the client from the form submitted by the user, and verify whether the length of the string sequence is 4. If the length is not 4, prompt the user that the verification code input is incorrect and enter a new round of verification;
[0029] If the length is 4, the string sequence is encrypted into a second-type 32-bit MD5 sequence code according to the MD5 encryption algorithm, and it is verified whether the second-type 32-bit MD5 sequence code is completely consistent with the first-type 32-bit MD5 sequence code used as the verification key. If they are completely consistent, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
[0030] A device for generating and verifying a picture verification code, the device comprising:
[0031] The image verification code generation module is used to construct a sequence library by summarizing and screening the regular Chinese short text sequences with a sequence length of 4, extract a set number of regular Chinese short text sequences from the sequence library to form a regular sequence list, and call the Chinese sequence pinyin length scrambling algorithm to scramble the characters of each regular Chinese short text sequence in the regular sequence list, and after obtaining the corresponding scrambled list, write each scrambled Chinese short text sequence in the scrambled list into the canvas set by initialization in combination with the sorting prompt information, generate the corresponding image verification code, and save the regular Chinese short text sequence corresponding to each image verification code as a file name for the image verification code, and obtain the image verification code set;
[0032] The picture verification code verification module is used to randomly read a picture verification code from the picture verification code set through the client for display when the user of the client enters the registration or login interface, and encrypt the file name of the picture verification code into a first-class serial code for identification; obtain the string sequence entered by the user after inference and sorting according to the picture verification code displayed by the client from the form submitted by the user, and perform length verification and key consistency verification on the string sequence in turn. When the length of the string sequence is 4 and the second-class serial code obtained after the string sequence is encrypted is completely consistent with the first-class serial code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
[0033] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0034] A sequence library is constructed by summarizing and screening the regular Chinese short text sequences with a sequence length of 4, a set number of regular Chinese short text sequences are extracted from the sequence library to form a regular list, and a Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each regular Chinese short text sequence in the regular list, and after obtaining the corresponding scrambled list, each scrambled Chinese short text sequence in the scrambled list is written into the canvas set by the initialization in combination with the sorting prompt information, a corresponding picture verification code is generated, and the regular Chinese short text sequence corresponding to each picture verification code is used as a file name to save the picture verification code, and a picture verification code set is obtained;
[0035] When the user of the client enters the registration or login interface, the client randomly reads a picture verification code from the picture verification code set for display, and encrypts the file name of the picture verification code into a first-class sequence code for identification;
[0036] The string sequence entered by the user after inference and sorting based on the image verification code displayed by the client is obtained from the form submitted by the user, and the length and key consistency verification are performed on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
[0037] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0038] A sequence library is constructed by summarizing and screening the regular Chinese short text sequences with a sequence length of 4, a set number of regular Chinese short text sequences are extracted from the sequence library to form a regular list, and a Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each regular Chinese short text sequence in the regular list, and after obtaining the corresponding scrambled list, each scrambled Chinese short text sequence in the scrambled list is written into the canvas set by the initialization in combination with the sorting prompt information, a corresponding picture verification code is generated, and the regular Chinese short text sequence corresponding to each picture verification code is used as a file name to save the picture verification code, and a picture verification code set is obtained;
[0039] When the user of the client enters the registration or login interface, the client randomly reads a picture verification code from the picture verification code set for display, and encrypts the file name of the picture verification code into a first-class sequence code for identification;
[0040] The string sequence entered by the user after inference and sorting based on the image verification code displayed by the client is obtained from the form submitted by the user, and the length and key consistency verification are performed on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
[0041] The above-mentioned method for generating and verifying a picture verification code has the following technical effects compared with the prior art:
[0042] 1. This application calls a Chinese sequence pinyin length scrambling algorithm to scramble a Chinese short text sequence containing correct semantic information, generates a picture verification code containing a scrambled Chinese short text sequence, and provides it to the client user. The client user correctly infers and sorts the scrambled Chinese short text sequence on the picture verification code, and then enters and submits the sorting result in the corresponding field in the client's login form to complete the identity authentication. It is very friendly to Chinese users with a certain amount of knowledge accumulation, but it is difficult for computer programs to crack the picture verification code. This application takes into account the usability and security criteria of the picture verification code design, and is suitable for user verification steps of large websites or online systems.
[0043] 2. This application generates a corresponding image verification code by writing each random Chinese short text sequence in the random list into the canvas initialized in combination with the sorting prompt information. The sorting prompt information can prompt the user to enter the character sequence in the correct word order, thereby reducing the error rate when the user identifies and enters the verification code. In addition, the background color and font color of the canvas initialized are different, and the colors of different characters in the canvas are different, so that the generated image verification code has high clarity, which can greatly enhance the user experience.
[0044] 3. When the image verification code is displayed on the client, the first type of serial code generated by encryption processing is used to replace the original file name of the image verification code and embedded in the client background for identification. This can effectively prevent the computer program from obtaining the correct plaintext key by directly parsing the page, further increasing the difficulty of cracking the image verification code.
[0045] 4. The image verification code generation process of this application supports the management party to dynamically expand the short text sequence data set. The dynamic expansion can not only increase the number of verification codes, thereby indirectly increasing the difficulty of machine cracking, but also meet the personalized needs of the management party, and make the image verification code into a knowledge verification system related to its own field. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1A schematic diagram of a flow chart of a method for generating and verifying a picture verification code in one embodiment;
[0047] Figure 2 The figure is a flow chart of a process of generating a picture verification code in one embodiment;
[0048] Figure 3 A schematic diagram of client service deployment in one embodiment;
[0049] Figure 4 A schematic diagram of a process of performing length verification and key consistency verification on a character string sequence input by a user during the verification process of a picture verification code in one embodiment;
[0050] Figure 5 It is a structural block diagram of a device for generating and verifying a picture verification code in one embodiment;
[0051] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0053] In one embodiment, Figure 1 As shown, a method for generating and verifying a picture verification code is provided, comprising the following steps:
[0054] Step S1, constructing a sequence library by aggregating and screening the regular Chinese short text sequences with a sequence length of 4, extracting a set number of regular Chinese short text sequences from the sequence library to form a regular list, and calling the Chinese sequence pinyin length scrambling algorithm to scramble the characters of each regular Chinese short text sequence in the regular list, after obtaining the corresponding scrambled list, write each scrambled Chinese short text sequence in the scrambled list into the canvas initialized in combination with the sorting prompt information, generate the corresponding picture verification code, and save the regular Chinese short text sequence corresponding to each picture verification code as the file name for the picture verification code, to obtain a picture verification code set.
[0055] Step S2, when the user of the client enters the registration or login interface, a picture verification code is randomly read from the picture verification code set by the client for display, and the file name of the picture verification code is encrypted into a first-class serial code for identification; the string sequence entered by the user after inference and sorting according to the picture verification code displayed by the client is obtained from the form submitted by the user, and the length of the string sequence and the key consistency verification are performed in turn. When the length of the string sequence is 4 and the second-class serial code obtained after the string sequence is encrypted is completely consistent with the first-class serial code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect, and enters a new round of verification.
[0056] In one embodiment, step S1 is a process of generating a picture verification code, and the specific steps are as follows: Figure 2 As shown, including:
[0057] 1) Load the deduplicated Chinese short text sequence dataset in rank order. Specifically, load the deduplicated Chinese idiom data, domain term data, and proper noun data respectively. Among them, the rank Chinese short text sequence dataset can be stored in three pre-defined text files, namely, idiom.txt, domain term.txt, and proper noun.txt, according to different data types. All files are saved in UTF-8 format, and each line contains only one Chinese short text sequence string. The default setting stores 40,000 Chinese idiom entries, 50,000 domain term entries, and 10,000 proper noun entries, totaling 100,000 data entries. It can also support the management party to dynamically expand data entries in the corresponding file according to the preset file encoding and data format, thereby increasing the capacity of the dataset.
[0058] 2) Traverse and filter the Chinese short text sequences with a sequence length of 4 in the Chinese short text sequence dataset and store them to construct a list-type sequence library.
[0059] 3) Randomly extract K (K cannot exceed the total number of sequences in the sequence library, by default, K is the total number of sequences in the sequence library) Chinese short text sequences in positive order to form a positive order list S k , by traversing the positive sequence list S in sequence k Each Chinese short text sequence in the right order is used, and the Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each Chinese short text sequence in the right order to obtain the corresponding scrambled list S k ’ ; Among them, the positive sequence list S k The Chinese short text sequence and random list S in the positive order k ’ Specifically, the specific steps of the Chinese sequence pinyin length randomization algorithm include:
[0060] 3.1) Input a Chinese short text sequence Seq1 with a sequence length of 4;
[0061] 3.2) Create a dictionary dicts to store temporary sorting results;
[0062] 3.3) Convert each character in the Chinese short text sequence Seq1 into the corresponding standard pinyin format without tone, and obtain a pinyin list L; specifically, the pypinyin open source toolkit implemented in Python language can be called to convert the characters into standard pinyin;
[0063] 3.4) Traverse each pinyin in the pinyin list L in turn, use the character corresponding to each pinyin as the key, and use the length of each pinyin as the value to form a key-value pair and store them in the dictionary dicts;
[0064] 3.5) Sort the keys in the dictionary dicts in ascending or descending order using a dictionary sorting algorithm according to the size of the values in the dictionary dicts, and save the sorting results in the S_List tuple list; specifically, the sorted dictionary sorting algorithm that comes with Python can be used for sorting;
[0065] 3.6) Initialize an empty string Seq2;
[0066] 3.7) Loop through the S_List tuple list 4 times, take out the current first key in the S_List tuple list as the character C, and concatenate them using the string concatenation method of Seq2=Seq2+C;
[0067] 3.8) Return Seq2 until the loop ends to obtain Seq2 with a sequence length of 4; wherein Seq2 with a sequence length of 4 is the disordered Chinese short text sequence corresponding to Seq1.
[0068] It can be understood that in addition to using the Chinese sequence pinyin length scrambling algorithm for scrambling operations, this application also supports the use of other scrambling algorithms (such as a scrambling algorithm using the number of character strokes) to complete the scrambling operation on the string sequence to obtain the corresponding new sequence after scrambling.
[0069] 4) Initialize the size and background color of the canvas and the type, size and color of the font, and set the initial storage location of the sorting prompt information to the upper left corner of the canvas. The background color of the canvas is different from the font color, and the colors of different characters in the canvas are different.
[0070] Specifically, the width and height of the canvas are set to 140x55, and the RGB values of the background colors of each channel of the canvas are randomly initialized to between (180, 255). In order to distinguish the background color of the canvas from the font color, the RGB values of the font colors of each channel are randomly initialized to between (30, 150). The font size of the random Chinese short text sequence in the canvas is 35, the font size of the sorting prompt information is 15, and all fonts in the canvas use the font format of the STKAITI.TTF type. Furthermore, the width and height of the canvas can be replaced with other sizes, the type and size of the font can also be replaced with other font sizes, and the background color and font color of the canvas can also be set to two other non-intersecting intervals between (0, 255).
[0071] It is understandable that with the above design strategy, it is impossible for the background and font to have exactly the same color in the same picture. This will not affect the clarity of the picture, but will also enhance the visual effect and improve the user experience to a certain extent.
[0072] 5) Traverse the random list S in sequence k ’ Each random Chinese short text sequence in the random list is written into the canvas of the initialization setting in combination with the sorting prompt information to generate the corresponding image verification code.
[0073] 6) The Chinese short text sequence corresponding to each image verification code is used as a file name to save the image verification code to obtain an image verification code set.
[0074] It can be understood that after obtaining the image verification code set, the image verification code set can be combined with the corresponding client App and deployed to the corresponding device to provide verification services according to the actual needs of the website or online system administrator, providing identity authentication functions for the registration and login of the client App. The deployment of the entire service on the client side is as follows: Figure 3 shown.
[0075] In one embodiment, step S2 is a verification process of a picture verification code, and the specific steps include:
[0076] 1) When the user of the client enters the registration or login interface of the website or online system, the client randomly reads a picture verification code from the picture verification code set for display, and encrypts the file name of the picture verification code into a first-class sequence code for identification. Specifically, the file name of the picture verification code is encrypted into a corresponding first-class 32-bit MD5 sequence code according to the MD5 encryption algorithm, and the first-class 32-bit MD5 sequence code is used as a verification key for identification in the client background.
[0077] It can be understood that replacing the original file name of the image verification code with the first type of 32-bit MD5 serial code and embedding it in the client backend for identification can effectively prevent computer programs from obtaining the correct plaintext key by directly parsing the page. In addition, this encrypted first type of 32-bit MD5 serial code can be used as the key to verify the content submitted by the user, which increases the difficulty of cracking the image verification code.
[0078] 2) Obtain the string sequence entered by the user after inference and sorting based on the image verification code displayed by the client from the form submitted by the user, and perform length verification and key consistency verification on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification. Specifically, the process of length verification and key consistency verification for the string sequence entered by the user is as follows Figure 4 As shown, including:
[0079] Obtain the string sequence T entered by the user after inference and sorting based on the image verification code displayed by the client from the form submitted by the user, and verify whether the length of the string sequence T is 4, that is, verify whether Len(T) is equal to 4. If the length is not 4, prompt the user that the verification code input is incorrect and enter a new round of verification; where Len() represents the sequence length;
[0080] If the length is 4, the string sequence T is encrypted into a second-class 32-bit MD5 sequence code according to the MD5 encryption algorithm, and the second-class 32-bit MD5 sequence code is verified to be completely consistent with the first-class 32-bit MD5 sequence code as the verification key, that is, whether MD5(T) is equal to the verification key. If they are completely consistent, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and a new round of verification begins. Among them, MD5(T) represents the second-class 32-bit MD5 sequence code obtained after the string sequence T is encrypted according to the MD5 encryption algorithm.
[0081] It can be understood that when the user of the client enters the registration or login page of the website or online system, he can see the corresponding account and password input boxes and the input box of the picture verification code. At this time, if the user wants to complete the registration or login, he needs to infer and sort the picture verification code displayed on the client page and enter the string sequence for verification. If the string sequence entered by the user does not meet the requirements or fails to match successfully, a corresponding error prompt will be given, and it will automatically return to the registration or login page to start a new round of verification code filling. If the 32-bit MD5 sequence code obtained by the specified MD5 encryption algorithm of the string sequence filled in by the user is exactly the same as the verification key, the verification is successful. Only then will it further check whether the account name or password field meets the format requirements set by the system. If it does not meet the requirements, the corresponding prompt information will be given and it will automatically return to the registration or login page. If it meets the requirements, the form will be submitted to the client's registration or login service to further verify the user's registration or login operation.
[0082] It should be understood that although Figure 1 , Figure 2 and Figure 4 The steps in the flowchart are shown in sequence as indicated by the arrows, but the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of the steps, and the steps can be executed in other orders. Moreover, Figure 1 , Figure 2 and Figure 4 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0083] In one embodiment, Figure 5 As shown, a device for generating and verifying a picture verification code is provided, comprising:
[0084] The picture verification code generation module 501 is used to construct a sequence library by summarizing and screening the regular Chinese short text sequences with a sequence length of 4, extract a set number of regular Chinese short text sequences from the sequence library to form a regular sequence list, and call the Chinese sequence pinyin length scrambling algorithm to scramble the characters of each regular Chinese short text sequence in the regular sequence list, after obtaining the corresponding scrambled list, write each scrambled Chinese short text sequence in the scrambled list into the canvas set by initialization in combination with the sorting prompt information, generate the corresponding picture verification code, and save the regular Chinese short text sequence corresponding to each picture verification code as a file name for the picture verification code, to obtain a picture verification code set;
[0085] The picture verification code verification module 502 is used to randomly read a picture verification code from the picture verification code set through the client for display when the user of the client enters the registration or login interface, and encrypt the file name of the picture verification code into a first-class serial code for identification; obtain the string sequence entered by the user after inference and sorting according to the picture verification code displayed by the client from the form submitted by the user, and perform length verification and key consistency verification on the string sequence in turn. When the length of the string sequence is 4 and the second-class serial code obtained after the string sequence is encrypted is completely consistent with the first-class serial code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
[0086] For the specific definition of the generation and verification device of the picture verification code, please refer to the definition of the generation and verification method of the picture verification code above, which will not be repeated here. Each module in the above-mentioned generation and verification device of the picture verification code can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0087] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for generating and verifying a picture verification code is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0088] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0089] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0090] A sequence library is constructed by summarizing and screening the regular Chinese short text sequences with a sequence length of 4, a set number of regular Chinese short text sequences are extracted from the sequence library to form a regular list, and a Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each regular Chinese short text sequence in the regular list, and after obtaining the corresponding scrambled list, each scrambled Chinese short text sequence in the scrambled list is written into the canvas set by the initialization in combination with the sorting prompt information, a corresponding picture verification code is generated, and the regular Chinese short text sequence corresponding to each picture verification code is used as a file name to save the picture verification code, and a picture verification code set is obtained;
[0091] When the user of the client enters the registration or login interface, the client randomly reads a picture verification code from the picture verification code set for display, and encrypts the file name of the picture verification code into a first-class sequence code for identification;
[0092] The string sequence entered by the user after inference and sorting based on the image verification code displayed by the client is obtained from the form submitted by the user, and the length and key consistency verification are performed on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
[0093] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0094] A sequence library is constructed by summarizing and screening the regular Chinese short text sequences with a sequence length of 4, a set number of regular Chinese short text sequences are extracted from the sequence library to form a regular list, and a Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each regular Chinese short text sequence in the regular list, and after obtaining the corresponding scrambled list, each scrambled Chinese short text sequence in the scrambled list is written into the canvas set by the initialization in combination with the sorting prompt information, a corresponding picture verification code is generated, and the regular Chinese short text sequence corresponding to each picture verification code is used as a file name to save the picture verification code, and a picture verification code set is obtained;
[0095] When the user of the client enters the registration or login interface, the client randomly reads a picture verification code from the picture verification code set for display, and encrypts the file name of the picture verification code into a first-class sequence code for identification;
[0096] The string sequence entered by the user after inference and sorting based on the image verification code displayed by the client is obtained from the form submitted by the user, and the length and key consistency verification are performed on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
[0097] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0098] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0099] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for generating and verifying a picture verification code, characterized in that: The method comprises: A sequence library is constructed by aggregating and screening the regular Chinese short text sequences with a sequence length of 4, a set number of regular Chinese short text sequences are extracted from the sequence library to form a regular list, and a Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each regular Chinese short text sequence in the regular list to obtain a corresponding scrambled list, and each scrambled Chinese short text sequence in the scrambled list is written into an initialized canvas in combination with sorting prompt information to generate a corresponding picture verification code, and the regular Chinese short text sequence corresponding to each picture verification code is used as a file name to save the picture verification code to obtain a picture verification code set; When the user of the client enters the registration or login interface, the client randomly reads a picture verification code from the picture verification code set for display, and encrypts the file name of the picture verification code into a first type of sequence code for identification; Obtain the string sequence entered by the user after inference and sorting based on the image verification code displayed by the client from the form submitted by the user, and perform length verification and key consistency verification on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification; The specific steps of the Chinese sequence pinyin length scrambling algorithm include: Input a Chinese short text sequence Seq1 with a sequence length of 4; Create a dictionary dicts to store temporary sorting results; Convert each character in the Chinese short text sequence Seq1 into a corresponding standard pinyin format without tone to obtain a pinyin list L; Traverse each pinyin in the pinyin list L in turn, use the character corresponding to each pinyin as a key, and use the length of each pinyin as a value to form a key-value pair and store them in the dictionary dicts; According to the size of the values in the dictionary dicts, the keys in the dictionary dicts are sorted in ascending or descending order using a dictionary sorting algorithm, and the sorting result is saved in the S_List tuple list; Initialize an empty string Seq2; Loop through the S_List tuple list 4 times, take out the current first key in the S_List tuple list as the character C respectively, and concatenate them using the string concatenation method of Seq2=Seq2+C; Return to Seq2 until the loop ends to obtain Seq2 with a sequence length of 4; wherein Seq2 with a sequence length of 4 is the disordered Chinese short text sequence corresponding to Seq1.
2. The method according to claim 1, characterized in that: The sequence library was constructed by summarizing and screening the Chinese short text sequences with a sequence length of 4, including: Loading a deduplicated rank-sequence Chinese short text sequence dataset; wherein the rank-sequence Chinese short text sequence dataset includes Chinese idiom data, domain term data, and proper noun data; By traversing and screening the regular Chinese short text sequences with a sequence length of 4 in the regular Chinese short text sequence data set and storing them, a list-type sequence library is constructed.
3. The method according to claim 2, characterized in that A set number of normal Chinese short text sequences are extracted from the sequence library to form a normal sequence list, and a Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each normal Chinese short text sequence in the normal sequence list to obtain a corresponding scrambled sequence list, including: Extract K Chinese short text sequences in positive order from the sequence library to form a positive order list S k , by traversing the positive sequence list S in sequence k Each Chinese short text sequence in the right order is used, and the Chinese sequence pinyin length scrambling algorithm is called to scramble the characters of each Chinese short text sequence in the right order to obtain the corresponding scrambled list S k ’ ; Wherein, the positive sequence list S k The Chinese short text sequence in the right order and the random order list S k ’ The random Chinese short text sequences in .
4. The method according to claim 1, characterized in that: The initialization settings of the canvas include: The size and background color of the canvas and the type, size and color of the font are initialized, and the initial storage position of the sorting prompt information is set to be located in the upper left corner of the canvas; wherein the background color of the canvas is different from the font color, and the colors of different characters in the canvas are different.
5. The method according to claim 1, characterized in that The file name of the image verification code is encrypted into a first-class serial code for identification, including: The file name of the image verification code is encrypted into a corresponding first-class 32-bit MD5 sequence code according to the MD5 encryption algorithm, and the first-class 32-bit MD5 sequence code is used as a verification key for identification in the client background.
6. The method according to claim 5, characterized in that Obtaining from the form submitted by the user a string sequence input by the user after inference and sorting based on the image verification code displayed by the client, and performing length verification and key consistency verification on the string sequence in turn. When the length of the string sequence is 4 and the second type of sequence code obtained after the string sequence is encrypted is completely consistent with the first type of sequence code, the user verification is successful; Otherwise, the user is prompted that the verification code is incorrect and a new round of verification begins, including: Obtain the string sequence entered by the user after inference and sorting based on the image verification code displayed by the client from the form submitted by the user, and verify whether the length of the string sequence is 4. If the length is not 4, prompt the user that the verification code input is incorrect and enter a new round of verification; If the length is 4, the string sequence is encrypted into a second-type 32-bit MD5 sequence code according to the MD5 encryption algorithm, and it is verified whether the second-type 32-bit MD5 sequence code is completely consistent with the first-type 32-bit MD5 sequence code serving as the verification key. If they are completely consistent, the user verification is successful; otherwise, the user is prompted that the verification code input is incorrect and enters a new round of verification.
7. A device for generating and verifying a picture verification code, characterized in that: The device comprises: A picture verification code generation module is used to construct a sequence library by summarizing and screening regular Chinese short text sequences with a sequence length of 4, extract a set number of regular Chinese short text sequences from the sequence library to form a regular list, and call a Chinese sequence pinyin length scrambling algorithm to scramble the characters of each regular Chinese short text sequence in the regular list, and after obtaining a corresponding scrambled list, write each scrambled Chinese short text sequence in the scrambled list into an initialized canvas in combination with sorting prompt information to generate a corresponding picture verification code, and save the regular Chinese short text sequence corresponding to each picture verification code as a file name for picture verification code, to obtain a picture verification code set; The picture verification code verification module is used to randomly read a picture verification code from the picture verification code set through the client for display when the user of the client enters the registration or login interface, and encrypt the file name of the picture verification code into a first-class sequence code for identification; obtain the string sequence entered by the user after inference and sorting according to the picture verification code displayed by the client from the form submitted by the user, and perform length verification and key consistency verification on the string sequence in turn. When the length of the string sequence is 4 and the second-class sequence code obtained after the string sequence is encrypted is completely consistent with the first-class sequence code, the user verification is successful; otherwise, the user is prompted that the verification code input is wrong and enters a new round of verification; The specific steps of the Chinese sequence pinyin length scrambling algorithm include: Input a Chinese short text sequence Seq1 with a sequence length of 4; Create a dictionary dicts to store temporary sorting results; Convert each character in the Chinese short text sequence Seq1 into a corresponding standard pinyin format without tone to obtain a pinyin list L; Traverse each pinyin in the pinyin list L in turn, use the character corresponding to each pinyin as a key, and use the length of each pinyin as a value to form a key-value pair and store them in the dictionary dicts; According to the size of the values in the dictionary dicts, the keys in the dictionary dicts are sorted in ascending or descending order using a dictionary sorting algorithm, and the sorting result is saved in the S_List tuple list; Initialize an empty string Seq2; Loop through the S_List tuple list 4 times, take out the current first key in the S_List tuple list as the character C respectively, and concatenate them using the string concatenation method of Seq2=Seq2+C; Return to Seq2 until the loop ends to obtain Seq2 with a sequence length of 4; wherein Seq2 with a sequence length of 4 is the disordered Chinese short text sequence corresponding to Seq1.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Text matching method and device, computer readable storage medium and computer equipment
CN112749539A
Novel verification code design method based on private information
CN115913622A