A method and system for generating and verifying a graphical verification code

By introducing a dynamic sinusoidal trajectory and rotation mechanism, combined with background motion rendering technology, the security and user experience of the slider CAPTCHA are improved. This solves the problems of easy cracking and high resource consumption in existing technologies, achieving higher security and user-friendliness.

CN120470576BActive Publication Date: 2026-02-10CHENGDU LAOYUAN INTELLIGENT TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510546938.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-28
Publication Date
2026-02-10
Estimated Expiration
2045-04-28

AI Technical Summary

Technical Problem

Existing slider CAPTCHAs are easily cracked by automated scripts, involve large amounts of data transmission, have a poor user experience, and are difficult to balance between ease of use and security.

Method used

It combines dynamic sinusoidal trajectory motion, slider rotation, and background motion. The background and slider patterns of the verification code are drawn using Canvas. When the user drags the slider, it is controlled to move in a wave-like motion along a dynamic sinusoidal trajectory. At the same time, the slider graphic rotates and the background pattern moves. Combined with the graphic matching verification mechanism, it ensures uniqueness and difficulty.

Benefits of technology

It significantly improves the security and resource efficiency of slider CAPTCHAs, enhances the user experience, and increases the difficulty of machine recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120470576B_ABST
    Figure CN120470576B_ABST
Patent Text Reader

Abstract

The embodiment of the specification provides a kind of graphical verification code generation and verification method and system, wherein, method includes: receiving the verification configuration parameter set issued by server;The verification configuration parameter set includes dynamic sinusoidal trajectory parameter, slider rotation rate parameter, background motion rate parameter and drawing seed parameter;Canvas is drawn according to the drawing seed parameter verification code background pattern and slider pattern;When user drags slider, control slider to do undulating motion along dynamic sinusoidal trajectory, simultaneously make slider graphic with configured slider rotation rate parameter rotates, and background pattern moves with configured background motion speed;When ball is dragged to target position, trigger graphical matching verification, whether ball is fused with background pattern target area is judged.The security of slider verification code, resource efficiency and user experience are significantly improved;It is suitable for various scenes needing user verification, with wide application prospect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This document relates to the fields of network security and user authentication technology, and in particular to a method and system for generating and verifying graphical CAPTCHAs. Background Technology

[0002] The Dynamic Image Alignment Verification System (Jigsaw Puzzle Slider CAPTCHA) is a security verification mechanism used to distinguish between human users and automated tools. It verifies authenticity by requiring users to complete an image alignment task. The system generates a background image and randomly cuts out a jigsaw puzzle piece at a specific location. Users drag a slider to move the puzzle piece to the correct position to complete the alignment. As the user drags the slider, the puzzle piece moves in real-time, providing intuitive visual feedback. The background remains unchanged while the slider is in motion, and there may be a clearly visible gap indicating the slider's endpoint. The system then detects the position and sliding trajectory of the puzzle piece to determine if it is a human operation, effectively preventing malicious crawlers, automated scripts, or bots from attacking and collecting data from the website.

[0003] Website developers need CAPTCHAs to prevent attacks from automated tools and malicious data collection, but CAPTCHA usability and security are difficult to balance. Traditional slider CAPTCHAs require users to drag a slider to a designated position, but they are easily cracked by automated scripts and involve large amounts of data transmission. Therefore, it is necessary to improve the existing slider CAPTCHA technology to address its low security, high resource consumption, and poor user experience, thereby enhancing user-friendliness and increasing the difficulty for machines to recognize it. Summary of the Invention

[0004] This specification provides one or more embodiments of a method for generating and verifying graphical verification codes, including:

[0005] Receive the verification configuration parameter set sent by the server; the verification configuration parameter set includes dynamic sine trajectory parameters, slider rotation rate parameters, background motion rate parameters, and drawing seed parameters;

[0006] The background and slider patterns for the verification code are drawn using the Canvas according to the drawing seed parameters.

[0007] When the user drags the slider, the slider is controlled to move in a wave-like motion along a dynamic sine trajectory. At the same time, the slider graphic rotates at the configured slider rotation rate parameter, and the background pattern moves at the configured background motion speed.

[0008] When the ball is dragged to the target position, a graphic matching verification is triggered to determine whether the ball blends with the target area of ​​the background pattern.

[0009] Furthermore, the dynamic sinusoidal trajectory parameters include amplitude, frequency, and phase. The server dynamically generates different batches of parameter combinations based on the user session ID or timestamp to ensure the uniqueness of the dynamic sinusoidal trajectory.

[0010] Furthermore, the slider rotation rate parameter includes an angular velocity value and a rotation direction, wherein the angular velocity value ranges from 0.5 to 3 rad / s, and the rotation direction is randomly selected between clockwise and counterclockwise.

[0011] Furthermore, the background motion rate parameter is the speed of uniform motion, with a value range of 10-50 pixels / second, and the phase difference between the background motion direction and the slider sinusoidal trajectory is 90°-270°.

[0012] Furthermore, the seed parameters include: background color gradient parameters, slider noise density parameters, and notch shape parameters; wherein, the color gradient parameters include the starting RGB value, the ending RGB value, and the gradient direction.

[0013] Furthermore, the image matching verification specifically includes:

[0014] Compare whether the offset between the final coordinates of the slider and the theoretical notch position is less than 3 pixels;

[0015] Verify whether the hash value of the slider's motion trajectory is consistent with the pre-generated sinusoidal trajectory parameters on the server;

[0016] The detection function checks whether the time difference between the start and end of dragging the slider conforms to the constraint relationship between the background motion speed and trajectory parameters.

[0017] Furthermore, the criterion for determining whether the small ball merges with the target area of ​​the background pattern is:

[0018] The color difference between the slider and the gap area in the background pattern is less than a preset threshold.

[0019] The overlap between the slider profile and the notch area profile is greater than 95%.

[0020] This specification provides one or more embodiments of a graphical CAPTCHA generation and verification system, including:

[0021] Parameter acquisition module: used to receive the verification configuration parameter set sent by the server; the verification configuration parameter set includes dynamic sine trajectory parameters, slider rotation rate parameters, background motion rate parameters and drawing seed parameters;

[0022] CAPTCHA generation module: used to draw the CAPTCHA background pattern and slider pattern using Canvas according to the drawing seed parameters;

[0023] Slider motion module: Used to control the slider to move in a wave-like motion along a dynamic sine trajectory when the user drags the slider, while the slider graphic rotates at the configured slider rotation rate parameter, and the background pattern moves at the configured background motion speed.

[0024] CAPTCHA verification module: used to trigger graphic matching verification when the ball is dragged to the target position, to determine whether the ball blends with the target area of ​​the background pattern.

[0025] This specification provides one or more embodiments of an electronic device, including:

[0026] Processor; and,

[0027] A memory is configured to store computer-executable instructions, which, when executed, cause the processor to implement the steps of the above-described graphical CAPTCHA generation and verification method.

[0028] This specification provides one or more embodiments of a storage medium for storing computer-executable instructions that, when executed, implement the steps of the above-described graphic verification code generation and verification method.

[0029] By incorporating dynamic sinusoidal trajectory motion, rotation mechanism, background motion, and configurable drawing technology, the security, resource efficiency, and user experience of slider CAPTCHAs are significantly improved. This invention is applicable to various scenarios requiring user verification and has broad application prospects.

[0030] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in one or more embodiments of this specification or in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0032] Figure 1 A flowchart illustrating a graphical verification code generation and verification method provided in one or more embodiments of this specification;

[0033] Figure 2 A schematic diagram illustrating the composition of a graphical verification code generation and verification system provided in one or more embodiments of this specification;

[0034] Figure 3 This is a schematic diagram of the structure of an electronic device provided for one or more embodiments of this specification. Detailed Implementation

[0035] To enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this document.

[0036] Method Implementation Examples

[0037] According to embodiments of the present invention, a method for generating and verifying graphical verification codes is provided. Figure 1 A flowchart illustrating a graphical verification code generation and verification method provided in one or more embodiments of this specification, such as... Figure 1 As shown, the graphical verification code generation and verification method according to an embodiment of the present invention specifically includes:

[0038] S1. Receive the verification configuration parameter set sent by the server; the verification configuration parameter set includes dynamic sine trajectory parameters, slider rotation rate parameters, background motion rate parameters, and drawing seed parameters.

[0039] The server generates dynamic sinusoidal trajectory parameters, slider rotation speed parameters, background motion speed parameters, and drawing seed parameters, and sends these parameters to the client; the client receives the verification configuration parameter set sent by the server.

[0040] In this embodiment, the dynamic sinusoidal trajectory parameters include amplitude, frequency, and phase; the slider rotation rate parameters include angular velocity and rotation direction, wherein the angular velocity ranges from 0.5 to 3 rad / s, and the rotation direction is randomly selected between clockwise and counterclockwise; the background motion rate parameter is the speed of uniform motion, ranging from 10 to 50 pixels / second, and the phase difference between the background motion direction and the slider sinusoidal trajectory is 90° to 270°.

[0041] The server dynamically generates different batches of parameter combinations based on the user session ID or timestamp of the application for verification, ensuring the uniqueness of the verification configuration parameters for each verification.

[0042] S2. Draw the verification code background pattern and slider pattern using the Canvas according to the drawing seed parameters.

[0043] The drawing seed parameters include: background color gradient parameters, slider noise density parameters, and notch shape parameters; wherein, the color gradient parameters include the starting RGB value, the ending RGB value, and the gradient direction. The CAPTCHA background pattern and slider pattern are drawn according to the drawing seed parameters to generate CAPTCHA image information, and then the operation to trigger the CAPTCHA is bound.

[0044] S3. When the user drags the slider, control the slider to move in a wave-like motion along a dynamic sine trajectory, while the slider graphic rotates at the configured slider rotation rate parameter, and the background pattern moves at the configured background motion speed.

[0045] The specific method for dynamically generating the sinusoidal wave trajectory of the ball as it is dragged, when controlling the slider to move in a wave-like motion along a dynamic sinusoidal trajectory, is as follows:

[0046] Randomly specify the endpoint of the ball within the background pattern;

[0047] Determine the predicted endpoint coordinates (x, y) of the ball, where y is the mapping of x according to the sine function f(x), as shown in the following formula:

[0048] f(x) = k*sin(x+t) + b;

[0049] Where k is the amplitude parameter and b is a fixed value set according to the height of the background pattern, used to constrain the sinusoidal trajectory of the ball's sliding so that it does not leave the background pattern;

[0050] The calculated relationship between the length x that the ball is dragged and the trajectory of the ball is (x, k*sin(ωx+t)+b), where x is determined by the length of the ball dragged by the user.

[0051] The slider graphic is rotated according to the configured slider rotation rate parameters. The specific method for configuring the rotation rate of the ball when it is dragged based on the slider rotation rate parameters is as follows:

[0052] Determine the predicted endpoint coordinates (x, y) of the ball, limit the rotation speed within a certain range, set a small random value k, and then use the following function:

[0053] f(x) = x * k;

[0054] Since k is a fixed value on the client side, we can know the mapping relationship between the user's slider drag length x and the rotation angle.

[0055] Find the angle at which the ball needs to rotate in the opposite direction when x is at 0.

[0056] S4. When the ball is dragged to the target position, the graphic matching verification is triggered to determine whether the ball blends with the target area of ​​the background pattern.

[0057] The graphic matching verification specifically includes:

[0058] The system compares the final coordinates of the slider with the theoretical gap position to see if the offset is less than 3 pixels. Specifically, the server calculates the theoretical gap coordinates that the slider should reach in real time based on dynamic parameters such as the amplitude, frequency, and phase of the sinusoidal trajectory. These coordinates are determined by the following factors: sinusoidal waveform superposition: the theoretical position is calculated based on the horizontal (X-axis) and vertical (Y-axis) amplitudes of the slider's wave motion, combined with the phase angle at the current time point; background motion compensation: the absolute coordinates of the gap in the canvas are dynamically corrected considering the translation speed and direction of the background pattern; and offset threshold control. To prevent machine positioning, operations with a matching error ≈ 0 are marked as suspicious.

[0059] Verify whether the hash value of the slider's motion trajectory is consistent with the pre-generated sinusoidal trajectory parameters on the server. Specifically, based on the issued sinusoidal trajectory parameters, such as amplitude, frequency, phase, and rotational speed, regenerate the standard motion curve. By calculating the actual trajectory and the theoretical trajectory, if the deviation exceeds a threshold, it is judged as abnormal.

[0060] The detection function checks whether the time difference between the start and end of dragging the slider conforms to the constraint relationship between the background motion speed and trajectory parameters.

[0061] The criteria for determining whether the small ball merges with the target area of ​​the background pattern are:

[0062] The color difference between the slider and the gap area in the background pattern is less than a preset threshold.

[0063] The overlap between the slider profile and the notch area profile is greater than 95%.

[0064] The beneficial effects of this invention are as follows:

[0065] By incorporating dynamic sinusoidal trajectory motion, rotation mechanism, background motion, and configurable drawing technology, the security, resource efficiency, and user experience of slider CAPTCHAs are significantly improved. This invention is applicable to various scenarios requiring user verification and has broad application prospects.

[0066] System Implementation Examples

[0067] According to embodiments of the present invention, a graphical verification code generation and verification system is provided. Figure 2 This specification provides a schematic diagram illustrating the composition of a graphical verification code generation and verification system according to one or more embodiments. Figure 2 As shown, the graphical verification code generation and verification system according to an embodiment of the present invention specifically includes:

[0068] Parameter acquisition module: used to receive the verification configuration parameter set sent by the server; the verification configuration parameter set includes dynamic sine trajectory parameters, slider rotation rate parameters, background motion rate parameters and drawing seed parameters;

[0069] CAPTCHA generation module: used to draw the CAPTCHA background pattern and slider pattern using Canvas according to the drawing seed parameters;

[0070] Slider motion module: Used to control the slider to move in a wave-like motion along a dynamic sine trajectory when the user drags the slider, while the slider graphic rotates at the configured slider rotation rate parameter, and the background pattern moves at the configured background motion speed.

[0071] CAPTCHA verification module: used to trigger graphic matching verification when the ball is dragged to the target position, to determine whether the ball blends with the target area of ​​the background pattern.

[0072] The embodiments of the present invention are system embodiments corresponding to the above method embodiments. The specific operation of each module can be understood by referring to the description of the method embodiments, and will not be repeated here.

[0073] Device Example 1

[0074] This invention provides an electronic device, such as... Figure 3 As shown, it includes: a memory 30, a processor 32, and a computer program stored in the memory 30 and executable on the processor 32. When the computer program is executed by the processor 32, it performs the following method steps:

[0075] S1. Receive the verification configuration parameter set sent by the server; the verification configuration parameter set includes dynamic sine trajectory parameters, slider rotation rate parameters, background motion rate parameters, and drawing seed parameters;

[0076] S2. Draw the verification code background pattern and slider pattern using the Canvas according to the drawing seed parameters;

[0077] S3. When the user drags the slider, control the slider to move in a wave-like motion along a dynamic sine trajectory, while the slider graphic rotates at the configured slider rotation rate parameter, and the background pattern moves at the configured background motion speed.

[0078] S4. When the ball is dragged to the target position, the graphic matching verification is triggered to determine whether the ball blends with the target area of ​​the background pattern.

[0079] Device Example 2

[0080] This invention provides a computer-readable storage medium storing an information transmission implementation program. When executed by a processor 32, the program performs the following method steps:

[0081] S1. Receive the verification configuration parameter set sent by the server; the verification configuration parameter set includes dynamic sine trajectory parameters, slider rotation rate parameters, background motion rate parameters, and drawing seed parameters;

[0082] S2. Draw the verification code background pattern and slider pattern using the Canvas according to the drawing seed parameters;

[0083] S3. When the user drags the slider, control the slider to move in a wave-like motion along a dynamic sine trajectory, while the slider graphic rotates at the configured slider rotation rate parameter, and the background pattern moves at the configured background motion speed.

[0084] S4. When the ball is dragged to the target position, the graphic matching verification is triggered to determine whether the ball blends with the target area of ​​the background pattern.

[0085] The computer-readable storage media described in this embodiment include, but are not limited to, ROM, RAM, disk, or optical disk.

[0086] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions 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 method for generating and verifying graphical CAPTCHAs, characterized in that, include: Receive the verification configuration parameter set sent by the server; the verification configuration parameter set includes dynamic sine trajectory parameters, slider rotation rate parameters, background motion rate parameters, and drawing seed parameters; The drawing seed parameters include: background color gradient parameters, slider noise density parameters, and notch shape parameters; wherein, the color gradient parameters include the starting RGB value, the ending RGB value, and the gradient direction; The background and slider patterns for the verification code are drawn using the Canvas according to the drawing seed parameters. When the user drags the slider, the slider is controlled to move in a wave-like motion along a dynamic sine trajectory. At the same time, the slider graphic rotates at the configured slider rotation rate parameter, and the background pattern moves at the configured background motion speed. When the slider graphic rotates at the configured slider rotation rate parameters, the rotation rate of the ball when it is dragged is configured based on the slider rotation rate parameters. The specific method is as follows: Determine the predicted endpoint coordinates (x, y) of the ball, set the slider rotation rate parameter to a random value k, and calculate the ball's rotation rate when being dragged using the following formula: f(x) = x*k; Where k is a fixed value on the client side, the angle at which the ball needs to rotate in the opposite direction when x is at 0 is found based on the mapping relationship between the length x dragged by the user's slider and the rotation angle. When the ball is dragged to the target position, a graphic matching verification is triggered to determine whether the ball blends with the target area of ​​the background pattern. The graphic matching verification specifically includes: Compare whether the offset between the final coordinates of the slider and the theoretical notch position is less than 3 pixels; Verify whether the hash value of the slider's motion trajectory is consistent with the pre-generated sinusoidal trajectory parameters on the server; The detection function checks whether the time difference between the start and end of dragging the slider conforms to the constraint relationship between the background motion speed and trajectory parameters.

2. The method according to claim 1, characterized in that, The dynamic sinusoidal trajectory parameters include amplitude, frequency, and phase. The server dynamically generates different batches of parameter combinations based on the user session ID or timestamp to ensure the uniqueness of the dynamic sinusoidal trajectory.

3. The method according to claim 1, characterized in that, The slider rotation rate parameters include angular velocity and rotation direction. The angular velocity ranges from 0.5 to 3 rad / s, and the rotation direction is randomly selected between clockwise and counterclockwise.

4. The method according to claim 1, characterized in that, The background motion rate parameter is the speed of uniform motion, with a value range of 10-50 pixels / second, and the phase difference between the background motion direction and the slider sinusoidal trajectory is 90°-270°.

5. The method according to claim 1, characterized in that, The criteria for determining whether the small ball merges with the target area of ​​the background pattern are: The color difference between the slider and the gap area in the background pattern is less than a preset threshold. The overlap between the slider profile and the notch area profile is greater than 95%.

6. A graphical verification code generation and verification system, characterized in that, include: Parameter acquisition module: used to receive the verification configuration parameter set sent by the server; the verification configuration parameter set includes dynamic sine trajectory parameters, slider rotation rate parameters, background motion rate parameters and drawing seed parameters; The drawing seed parameters include: background color gradient parameters, slider noise density parameters, and notch shape parameters; wherein, the color gradient parameters include the starting RGB value, the ending RGB value, and the gradient direction; CAPTCHA generation module: used to draw the CAPTCHA background pattern and slider pattern using Canvas according to the drawing seed parameters; Slider motion module: Used to control the slider to move in a wave-like motion along a dynamic sine trajectory when the user drags the slider, while the slider graphic rotates at the configured slider rotation rate parameter, and the background pattern moves at the configured background motion speed. When the slider graphic rotates at the configured slider rotation rate parameters, the rotation rate of the ball when it is dragged is configured based on the slider rotation rate parameters. The specific method is as follows: Determine the predicted endpoint coordinates (x, y) of the ball, set the slider rotation rate parameter to a random value k, and calculate the ball's rotation rate when being dragged using the following formula: f(x) = x*k; Where k is a fixed value on the client side, the angle at which the ball needs to rotate in the opposite direction when x is at 0 is found based on the mapping relationship between the length x dragged by the user's slider and the rotation angle. CAPTCHA verification module: used to trigger graphic matching verification when the ball is dragged to the target position, to determine whether the ball blends with the target area of ​​the background pattern; The graphic matching verification specifically includes: Compare whether the offset between the final coordinates of the slider and the theoretical notch position is less than 3 pixels; Verify whether the hash value of the slider's motion trajectory is consistent with the pre-generated sinusoidal trajectory parameters on the server; The detection function checks whether the time difference between the start and end of dragging the slider conforms to the constraint relationship between the background motion speed and trajectory parameters.

7. An electronic device, characterized in that, include: processor; as well as, A memory configured to store computer-executable instructions, which, when executed, cause the processor to implement the steps of the graphical CAPTCHA generation and verification method as described in any one of claims 1 to 5.

8. A storage medium, characterized in that, Used to store computer-executable instructions, which, when executed, implement the steps of the graphical CAPTCHA generation and verification method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Verification code processing method based on WEB page

    CN106778568A

  • Authentication code implementation method, apparatus, system, computing device and storage medium

    CN109063453A