Character click verification code generation method and device, terminal equipment and storage medium
By using mask repainting technology in the text click verification code to generate synthetic pictures with missing edges, the poor user experience caused by excessive distortion of existing verification codes is solved, and a defense and user-friendly solution for automated attacks is achieved.
Patent Information
- Application Number
- CN202411255306.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-09-09
AI Technical Summary
The existing text click verification code has added too many distortions and deformations, resulting in poor user experience, especially unfriendly to automated attacks and visually impaired users.
By randomly selecting vocabulary groups from the preset Chinese phrase database, a text picture with a white background and a black font is generated, and a mask-repainting is used to use literary and biographical technology to generate synthetic pictures to ensure that there are missing edges of text, thereby improving verification The difficulty of cracking code while maintaining user-friendliness.
Effectively prevent automated tools from identifying verification codes, while human users can easily identify and click verification codes, improving user experience, taking into account both difficult cracking and user-friendliness.
Smart Images

Figure CN119293773A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of verification code recognition, and in particular to a method, device, terminal equipment and storage medium for generating a text-click verification code. Background Art
[0002] Existing text-click verification codes have limited defense capabilities against automated attacks: Although text-click verification codes are designed to prevent automated attacks, with the development of technology, advances in machine learning and image recognition technology may make such verification code systems more easily cracked by automated tools, such as WeChat text extraction functions. In order to increase the difficulty of cracking, some verification systems add too much distortion to the text. Excessive distortion may require extra time and effort to accurately identify and click the text in the verification code, which will interfere with users and reduce the user experience, especially for visually impaired users. Summary of the invention
[0003] The present invention provides a method, device, terminal device and storage medium for generating a text-click verification code, so as to solve the technical problem that the prior art adds too much distortion to the question, resulting in poor user experience.
[0004] In order to solve the above technical problems, an embodiment of the present invention provides a method for generating a text-click verification code, comprising:
[0005] Randomly select one or more words from a preset Chinese phrase database as a vocabulary group;
[0006] According to the vocabulary group, a text image with a white background and black font is generated;
[0007] Generate a content image based on the vocabulary group using text graph technology;
[0008] Using the text image as a mask image and the content image as a target image, performing mask redrawing to generate a composite image; wherein the edges of the text in the composite image are missing;
[0009] The vocabulary group and the composite image are uploaded to a text click verification code database.
[0010] As a preferred solution, generating a text image with a white background and black font according to the vocabulary group includes:
[0011] Counting the number of characters in the vocabulary group;
[0012] Generate a white background image, and divide the background image into a corresponding number of regions according to the number of characters; wherein no two regions overlap each other;
[0013] Scrambling the order of the characters in the vocabulary group to generate a new character sequence;
[0014] According to the character sequence, a corresponding character in black font is generated in each of the regions in turn.
[0015] As a preferred solution, the font parameter settings in the text image include:
[0016] Set the font type to Microsoft YaHei;
[0017] Set the font style to bold;
[0018] Set the font size to 256;
[0019] Set the vertical font scaling to 150%;
[0020] Set the horizontal font scaling to 130%.
[0021] As a preferred solution, the method of generating a content image based on the vocabulary group using the text graph technology includes:
[0022] The words in the vocabulary group are used as prompt words, and the text map function of the Stab le Diffus ion XL model is used to generate content pictures.
[0023] As a preferred solution, the step of using the text image as a mask image and the content image as a target image to perform mask redrawing to generate a composite image includes:
[0024] Overlapping the mask image and the target image;
[0025] The mask image and the target image are input into a mask redrawing tool so that the overlapping portion of the target image and the black portion of the mask image is modified, and a composite image is output.
[0026] As a preferred solution, the parameter configuration of the mask redrawing tool includes:
[0027] Set the image sampling step to 32;
[0028] Set the image sampler to DPM++2M Karras;
[0029] Set the composite image resolution to 1024×1024;
[0030] Set the synthetic image generation model to sd_x l_base_1.0;
[0031] Set the redraw amplitude to 0.8;
[0032] Set up a Tuya Control Net module and a Deep Control Net module;
[0033] Set the model used by the Tuya Control Net module to sai_x l_sketch_256l ora;
[0034] The model used by the depth Control Net module is set to sai_x l_depth_256l ora.
[0035] Based on the above embodiment, another embodiment of the present invention provides a text-click verification code generation device, including: a text acquisition module, a mask image generation module, a target image generation module, a mask redrawing module and a data upload module;
[0036] The text acquisition module is used to randomly select one or more words from a preset Chinese phrase database as a vocabulary group;
[0037] The mask image generation module is used to generate a text image with a white background and black fonts according to the vocabulary group;
[0038] The target image generation module is used to generate a content image based on the vocabulary group using the text graph technology;
[0039] The mask redrawing module is used to use the text image as the mask image and the content image as the target image to perform mask redrawing to generate a composite image; wherein the edges of the text in the composite image are missing;
[0040] The data uploading module is used to upload the vocabulary group and the composite image to a text click verification code database.
[0041] Based on the above embodiments, another embodiment of the present invention provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, the text-click verification code generation method described in the above invention embodiment is implemented.
[0042] Based on the above embodiments, another embodiment of the present invention provides a storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the text-click verification code generation method described in the above invention embodiment.
[0043] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0044] The present invention generates a text image and a content image according to a randomly selected vocabulary group; then the text image is used as a mask image, and the content image is used as a target image, and the mask is redrawn to generate a composite image; finally, the vocabulary group and the composite image are uploaded to a text click verification code database. Although the text in the composite image generated by the present invention does not have any distortion effect, because the text edge is missing in the image after the mask is redrawn, the text and the picture can be merged, which makes it impossible for automated text tools to recognize these texts. However, human cognitive function has the principle of completeness and closure tendency for graphics and backgrounds, so that our brain tends to see a complete graphic even if it sees incomplete edges. Therefore, the present invention takes into account the advantages of being difficult to crack and user-friendly at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a flowchart of a method for generating a text-click verification code provided by an embodiment of the present invention;
[0046] Figure 2 is a text image generated in one embodiment of the present invention;
[0047] Figure 3 is a content picture generated in an embodiment of the present invention;
[0048] Figure 4 is a composite picture generated in one embodiment of the present invention;
[0049] Figure 5 It is a structural schematic diagram of a text-click verification code generating device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned figure descriptions are intended to cover non-exclusive inclusions. "Several" means two or more.
[0052] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not 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.
[0054] Embodiment 1
[0055] Please refer to Figure 1 , is a flow chart of a method for generating a text-click verification code provided by an embodiment of the present invention, comprising:
[0056] S1. Randomly select one or more words from a preset Chinese phrase database as a vocabulary group.
[0057] It should be noted that the Chinese phrase database can be manually imported into a batch of selected phrases, or a batch of phrases can be automatically generated and imported using a large language model.
[0058] In step S1, one or more words are randomly selected from the Chinese word group data as a word group, for example, milk, bread.
[0059] S2. Generate a text image with a white background and black fonts according to the vocabulary group.
[0060] In step S2, a text image with a white background and black fonts is automatically generated using a Photoshop script according to the vocabulary group.
[0061] It should be noted that the pixel size of the text image is 1024×1024.
[0062] In a preferred embodiment, generating a text image with a white background and black font according to the vocabulary group includes:
[0063] Counting the number of characters in the vocabulary group;
[0064] Generate a white background image, and divide the background image into a corresponding number of regions according to the number of characters; wherein no two regions overlap each other;
[0065] Scrambling the order of the characters in the vocabulary group to generate a new character sequence;
[0066] According to the character sequence, a corresponding character in black font is generated in each of the regions in turn.
[0067] In this embodiment, the number of characters in a phrase is limited to 3-4.
[0068] Count the number of characters in the vocabulary group, for example, the number of characters in "milk bread" is 4.
[0069] Generate a white background image with a size of 1024×1024. Divide the background image into four different areas, namely the first area, the second area, the third area and the fourth area. These four areas do not overlap with each other.
[0070] The order of the words in the word picture can be arranged arbitrarily. Shuffle the words in the vocabulary group to generate a new word sequence. For example, the possible word sequences of the vocabulary group [milk, bread] are: milk bread, milk noodles, cow noodles milk, cow bread milk, cow noodles, cow noodles milk, cow bread, cow noodles, milk noodles cow bread, milk bread cow, milk cow noodles, milk noodles cow, milk bread cow, milk cow noodles, milk noodles cow, milk milk bun, cow noodles, cow milk bun, cow milk bun, cow milk bun, bread milk cow, bread cow, bread milk, bread cow, cow milk noodles, cow noodles milk, cow noodles, cow milk noodles, cow noodles, cow milk noodles, cow noodles, cow milk noodles, cow noodles, cow milk and cow noodles.
[0071] Taking the text sequence "milk and bread" as an example, according to the first character "cow" in the text sequence, a corresponding black text image is generated in the first area; according to the second character "milk" in the text sequence, a corresponding black text image is generated in the second area; according to the third character "noodles" in the text sequence, a corresponding black text image is generated in the third area; according to the fourth character "package" in the text sequence, a corresponding black text image is generated in the fourth area, and the following is obtained: Figure 2 Text image shown.
[0072] Although the generated text images are in different areas, we should try to ensure that there is a certain distance between the text graphics and a certain distance between the text graphics and the edge of the background image.
[0073] The synthetic image generated by the text-click verification code generation method provided by the present invention has no distortion effect on the text, but because the text edge is missing in the image after the mask is redrawn, the text and the picture can be merged, which makes it impossible for the automated text tool to recognize these texts. The human cognitive function has the principle of completeness and closure tendency for graphics and backgrounds, so that our brain tends to see a complete graphic even if it sees incomplete edges. Therefore, the present invention takes into account the advantages of being difficult to crack and user-friendly at the same time.
[0074] In a preferred embodiment, the first area is the upper left area of the background image; the second area is the upper right area of the background image; the third area is the lower left area of the background image; and the fourth area is the lower right area of the background image.
[0075] In this embodiment, the white background image is equally divided into four areas: upper left, upper right, lower left and lower right. The upper left area is the first area, the upper right area is the second area, the lower left area is the third area, and the lower right area is the fourth area.
[0076] In a preferred embodiment, the font parameter settings in the text image include:
[0077] Set the font type to Microsoft YaHei;
[0078] Set the font style to bold;
[0079] Set the font size to 256;
[0080] Set the vertical font scaling to 150%;
[0081] Set the horizontal font scaling to 130%.
[0082] In this embodiment, the font in the text image is required to be conspicuous enough, so the font type is set to Microsoft YaHei, the style is set to bold, the size is set to 256, the vertical zoom ratio is set to 150%, and the horizontal zoom ratio is set to 130%. Such settings can make the composite image generated by the subsequent mask redrawing easy for users to recognize.
[0083] S3. Generate a content image based on the vocabulary group using text-based graph technology.
[0084] In a preferred embodiment, the generating of content images using the text graph technology according to the vocabulary group includes:
[0085] The words in the vocabulary group are used as prompt words, and the text image function of the Staple Diffusion XL model is used to generate a content image.
[0086] In this embodiment, the words "milk" and "bread" in the vocabulary group are used as prompt words, and the text map function of the Stable Diffusion XL model is used to generate the following Figure 3 Content image shown.
[0087] It should be noted that the content image is an image that is intelligently generated based on the meaning of the vocabulary, and the image content is related to the meaning of the vocabulary.
[0088] S4. Using the text image as a mask image and the content image as a target image, redrawing the mask to generate a composite image; wherein the edges of the text in the composite image are missing.
[0089] In a preferred embodiment, the step of using the text image as a mask image and the content image as a target image to perform mask redrawing to generate a composite image includes:
[0090] Overlapping the mask image and the target image;
[0091] The mask image and the target image are input into a mask redrawing tool so that the overlapping portion of the target image and the black portion of the mask image is modified, and a composite image is output.
[0092] It should be noted that the mask is used to define which parts of the image should be edited, retained or displayed. The black area (i.e. the text area) on the mask will determine which parts of the target image will be redrawn or modified. Usually, the white area on the mask image indicates that the corresponding part of the target image needs to be retained or displayed, while the black area indicates that the corresponding part of the target image will be hidden or modified.
[0093] In this embodiment, the content image is the target image, and the target image refers to the image affected and modified by the mask. In the process of modifying the target image, the mask image is used to guide the editing of the target image, and finally the following is generated: Figure 4 Composite image shown.
[0094] It should also be noted that the mask redrawing function used in the present invention processes the edge of the mask image to make the edge missing or blurred. The commonly used processing method is to feather the mask to blur the boundary between the black and white areas of the mask image, so that the edges of the generated composite image are blurred and missing.
[0095] In a preferred embodiment, the parameter configuration of the mask redrawing tool includes:
[0096] Set the image sampling step to 32;
[0097] Set the image sampler to DPM++2M Karras;
[0098] Set the composite image resolution to 1024×1024;
[0099] Set the synthetic image generation model to sd_x l_base_1.0;
[0100] Set the redraw amplitude to 0.8;
[0101] Set up a Tuya Control Net module and a Deep Control Net module;
[0102] Set the model used by the Tuya Control Net module to sai_x l_sketch_256l ora;
[0103] The model used by the depth Control Net module is set to sai_x l_depth_256l ora.
[0104] In this embodiment, the image sampling deployment specifies the number of sampling steps when generating an image, which is set to 32. The image sampler specifies the sampler used to generate the image, which is set to DPM++2M Karras. The synthetic image resolution defines the size of the generated image, which is set to 1024x1024. The synthetic image generation model specifies the model used to generate the image, which is set to "sd_xl_base_1.0". The redraw amplitude determines the degree of modification to the target image during the mask redrawing process, which is set to 0.8. Two different Control Net modules and their corresponding models are specified, one is the graffiti Control Net module, and the other is the depth Control Net module. The graffiti Control Net module is set to the sai_x l_sketch_256l ora model, and the depth Control Net module is set to the sai_x l_sketch_256l ora model.
[0105] S5. Upload the vocabulary group and the composite image to a text-click verification code database.
[0106] It should be noted that the method of using the text click verification code includes:
[0107] A composite image and a corresponding vocabulary group are accumulated and selected from a text click verification code database;
[0108] Randomly adjust the order of the characters in the vocabulary group to obtain a character sequence as the verification code sequence;
[0109] Display the composite image to the user, and wait for the user to click on the area corresponding to different texts in the composite image;
[0110] Obtain the text sequence selected by the user according to the user's click order as the sequence to be verified;
[0111] Compare the verification code sequence with the sequence to be verified. If the text sequences are consistent, the verification passes, otherwise it fails.
[0112] Embodiment 2
[0113] Please refer to Figure 5 , is a structural diagram of a text-click verification code generation device provided by an embodiment of the present invention, comprising: a text acquisition module, a mask image generation module, a target image generation module, a mask redrawing module and a data upload module;
[0114] The text acquisition module is used to randomly select one or more words from a preset Chinese phrase database as a vocabulary group;
[0115] The mask image generation module is used to generate a text image with a white background and black fonts according to the vocabulary group;
[0116] The target image generation module is used to generate a content image based on the vocabulary group using the text graph technology;
[0117] The mask redrawing module is used to use the text image as the mask image and the content image as the target image to perform mask redrawing to generate a composite image; wherein the edges of the text in the composite image are missing;
[0118] The data uploading module is used to upload the vocabulary group and the composite image to a text click verification code database.
[0119] Embodiment 3
[0120] Accordingly, an embodiment of the present invention provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, the text-click verification code generation method described in the above-mentioned embodiment of the invention is implemented.
[0121] Embodiment 4
[0122] Accordingly, an embodiment of the present invention provides a storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the text-click verification code generation method described in the above-mentioned embodiment of the invention.
[0123] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0124] Those skilled in the art can clearly understand that for the sake of convenience and brevity, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0125] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.
[0126] The processor may be a central processing unit (CPU), or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the device, and various interfaces and lines are used to connect various parts of the entire device.
[0127] The memory can be used to store the computer program, and the processor realizes various functions of the device by running or executing the computer program stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Med ia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Fl ash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0128] The storage medium is a storage medium, and the computer program is stored in the storage medium. When the computer program is executed by the processor, the steps of each method embodiment described above can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-On l yMemory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer readable media do not include electric carrier signals and telecommunication signals.
[0129] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for generating a text-click verification code, characterized in that: include: Randomly select one or more words from a preset Chinese phrase database as a vocabulary group; According to the vocabulary group, a text image with a white background and black font is generated; Generate a content image based on the vocabulary group using text graph technology; Using the text image as a mask image and the content image as a target image, performing mask redrawing to generate a composite image; wherein the edges of the text in the composite image are missing; The vocabulary group and the composite image are uploaded to a text click verification code database.
2. The method for generating a text-click verification code according to claim 1, wherein: The step of generating a text image with a white background and black fonts according to the vocabulary group includes: Counting the number of characters in the vocabulary group; Generate a white background image, and divide the background image into a corresponding number of regions according to the number of characters; wherein no two regions overlap each other; Scrambling the order of the characters in the vocabulary group to generate a new character sequence; According to the character sequence, a corresponding character in black font is generated in each of the regions in turn.
3. The method for generating a text-click verification code according to claim 1, wherein: The font parameter settings in the text image include: Set the font type to Microsoft YaHei; Set the font style to bold; Set the font size to 256; Set the vertical font scaling to 150%; Set the horizontal font scaling to 130%.
4. The method for generating a text-click verification code according to claim 1, wherein: The step of generating a content image based on the vocabulary group using a text graph technology includes: The words in the vocabulary group are used as prompt words, and the text map function of the Stable Diffusion XL model is used to generate content pictures.
5. The method for generating a text-click verification code according to claim 1, wherein: The step of using the text image as a mask image and the content image as a target image to perform mask redrawing to generate a composite image includes: Overlapping the mask image and the target image; The mask image and the target image are input into a mask redrawing tool so that the overlapping portion of the target image and the black portion of the mask image is modified, and a composite image is output.
6. The method for generating a text-click verification code as claimed in claim 5, wherein: The parameter configuration of the mask redrawing tool includes: Set the image sampling step to 32; Set the image sampler to DPM++2M Karras; Set the composite image resolution to 1024×1024; Set the synthetic image generation model to sd_xl_base_1.0; Set the redraw amplitude to 0.8; Set up a Tuya ControlNet module and a Deepin ControlNet module; Set the model used by the Tuya ControlNet module to sai_xl_sketch_256lora; The model used by the deep ControlNet module is set to sai_xl_depth_256lora.
7. A text-click verification code generation device, characterized in that: include: Text acquisition module, mask image generation module, target image generation module, mask redrawing module and data upload module; The text acquisition module is used to randomly select one or more words from a preset Chinese phrase database as a vocabulary group; The mask image generation module is used to generate a text image with a white background and black fonts according to the vocabulary group; The target image generation module is used to generate a content image based on the vocabulary group using the text graph technology; The mask redrawing module is used to use the text image as the mask image and the content image as the target image to perform mask redrawing to generate a composite image; wherein the edges of the text in the composite image are missing; The data uploading module is used to upload the vocabulary group and the composite image to a text click verification code database.
8. A terminal device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the method for generating a text-click verification code as described in any one of claims 1 to 6 is implemented.
9. A storage medium, characterized in that: The storage medium includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the text-click verification code generation method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Click verification code identification method and device, and user terminal
CN108182437A
Click verification code recognition method and device, computer equipment and storage medium
CN111737548A
Multi-element semantic verification code and generation method thereof
CN116451207A
Image generation method and device, electronic equipment and storage medium
CN117351116A