Verification code generation method and device and storage medium

By obtaining the server load parameters in the verification code generation method and selecting the server with the lowest load to generate the verification code, the problem of low verification code transmission efficiency is solved, the user experience and system performance are improved, and load balancing is achieved.

CN119254480APending Publication Date: 2025-01-03YOUDI ROBOT (WUXI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411329244.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

In modern Internet applications, the efficiency of sending verification codes to the user side is slow, resulting in users failing to receive verification codes in a timely manner within the valid time, affecting the user experience and the load balancing of the system.

Method used

When obtaining the request by detecting the verification code of the user side, the load parameters of each server are obtained, the target server with the lowest load is determined, and the verification code is generated and sent on the server, and efficient data exchange is achieved using the WebSocket protocol.

Benefits of technology

It improves the efficiency of verification code generation, reduces user waiting time, improves system response speed, ensures the rational use of server resources, and avoids overloading of some servers while other servers are idle.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119254480A_ABST
    Figure CN119254480A_ABST
Patent Text Reader

Abstract

The invention discloses a verification code generation method and device and a storage medium, and relates to the technical field of verification codes, and the method comprises the steps: obtaining a load parameter of each server when a verification code obtaining request sent by a user side is detected; according to the load parameter of each server, determining a target server in each server; and the target server generates a target verification code according to the verification code acquisition request, and sends the target verification code to the user side. The generation efficiency of the verification code can be improved, and the situation that the user does not receive the verification code within the effective time is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of verification code technology, and in particular to a verification code generation method, device and storage medium. Background Art

[0002] In modern Internet applications, SMS verification codes are widely used in scenarios such as user registration, login, password retrieval, and payment confirmation to ensure the security of user accounts and the legality of operations.

[0003] When the server sends the verification code to the user, it is often accompanied by a large amount of other data, which results in a slow efficiency in sending the verification code to the user. At the same time, because the verification code has a short validity period, the user may not receive the verification code within the validity period and cannot verify in time.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of this application is to provide a verification code generation method, device and storage medium, aiming to solve the technical problem of how to improve the generation efficiency of the verification code and avoid the user end not receiving the verification code within the valid time.

[0006] To achieve the above purpose, the present application proposes a verification code generation method, the method comprising:

[0007] When a verification code acquisition request sent by a user is detected, load parameters of each server are acquired;

[0008] Determining a target server from among the servers according to the load parameters of the servers;

[0009] The target server generates a target verification code according to the verification code acquisition request, and sends the target verification code to the user terminal.

[0010] In one embodiment, the load parameters include the number of connections and the response time; and the step of determining a target server from among the servers according to the load parameters of the servers includes:

[0011] Determine the weight ratios corresponding to the number of connections and the response time, respectively, and calculate the total score of the load parameters of each of the servers, wherein the weight ratio of the number of connections is less than the weight ratio of the response time;

[0012] The server corresponding to the largest total score is determined as the target server.

[0013] In one embodiment, the target server generates a target verification code according to the verification code acquisition request, and sends the target verification code to the user terminal, including:

[0014] When the target server receives the verification code acquisition request, a connection is established between the target server and the encoding module;

[0015] The target server generates a first verification code according to the verification code acquisition request, and sends the first verification code to the encoding module;

[0016] Determine a preset encoding rule according to the encoding module, perform sequence number arrangement and feature arrangement on the first verification code according to the preset encoding rule to generate the target verification code, and send the target verification code to the target server;

[0017] The target verification code is sent to the user terminal according to the target server.

[0018] In one embodiment, the step of determining a preset encoding rule according to the encoding module includes:

[0019] Acquire a historical target verification code according to the encoding module, and determine a sequence number arrangement rule and a feature arrangement rule according to the historical target verification code;

[0020] respectively adjusting the parameters of the sequence number arrangement rule and the feature arrangement rule;

[0021] The serial number arrangement rule and the feature arrangement rule after parameter adjustment are determined as the preset coding rule.

[0022] In one embodiment, the step of establishing a connection between the target server and the encoding module includes:

[0023] The target server establishes a connection with the encoding module via the WebSocket protocol.

[0024] In one embodiment, after the step of sending the target verification code to the user terminal according to the target server, the method further includes:

[0025] Acquire the sending time of the target verification code, and associate the target verification code with the sending time;

[0026] The associated target verification code is stored.

[0027] In one embodiment, the method further comprises:

[0028] When the verification request sent by the user terminal is obtained, the verification request is parsed to obtain a second verification code;

[0029] The associated target verification code is obtained, and whether the verification is successful is determined according to the target verification code and the second verification code.

[0030] In one embodiment, the step of determining whether verification is passed according to the target verification code and the second verification code includes:

[0031] Determining the validity time according to the sending time of the target verification code;

[0032] Determining whether the reception time of the second verification code is within the valid time, and determining whether the target verification code and the second verification code are the same;

[0033] If the target verification code is the same as the second verification code, and the receiving time of the second verification code is within the valid time, it is determined that the verification is passed;

[0034] If the target verification code and the second verification code are different, and / or the reception time of the second verification code is not within the valid time, the verification fails, and an error prompt is sent to the user terminal.

[0035] In addition, to achieve the above-mentioned purpose, the present application also proposes a verification code generation device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the verification code generation method described above.

[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the verification code generation method described above are implemented.

[0037] The present application provides a verification code generation method, which obtains the load parameters of each server after detecting the verification code acquisition request sent by the user end, and determines the server that generates the verification code according to the load parameters. By assigning the verification code generation task to the server with the lowest load, the user's waiting time can be reduced, the system's response speed can be increased, and the user experience can be improved. In addition, it can also ensure that all servers in the system can be reasonably utilized, avoiding some servers from being overloaded due to processing too many requests while other servers are idle. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0039] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0040] Figure 1 A flowchart of the first embodiment of the verification code generation method of this application is provided;

[0041] Figure 2 A detailed flow chart of the first embodiment of the verification code generation method of this application is provided;

[0042] Figure 3 Another detailed flow chart of the first embodiment of the verification code generation method of this application is provided;

[0043] Figure 4 A flowchart of the second embodiment of the verification code generation method of this application is provided;

[0044] Figure 5 A flowchart of the third embodiment of the verification code generation method of this application is provided;

[0045] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the verification code generation method in the embodiment of the present application.

[0046] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0047] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0048] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0049] The main solution of the embodiment of the present application is: when a verification code acquisition request sent by a user terminal is detected, the load parameters of each server are obtained; according to the load parameters of each server, a target server is determined among the servers; the target server generates a target verification code according to the verification code acquisition request, and sends the target verification code to the user terminal.

[0050] At present, when the server sends the verification code to the user, it is often accompanied by a large amount of other data, which results in a relatively slow efficiency in sending the verification code to the user. At the same time, because the verification code has a relatively short validity period, the user may not receive the verification code within the validity period and cannot perform verification in time.

[0051] In order to solve the above problems, the present application provides a verification code generation method. After detecting the verification code acquisition request sent by the user end, the load parameters of each server are obtained, and the server generating the verification code is determined according to the load parameters. By assigning the verification code generation task to the server with the lowest load, the user's waiting time can be reduced, the system's response speed can be increased, and the user experience can be improved. In addition, it can also ensure that all servers in the system can be reasonably utilized, avoiding some servers from being overloaded due to processing too many requests while other servers are idle.

[0052] It should be noted that the execution subject of this embodiment can be a computing service device with network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, a server, a server cluster, etc., or an electronic device capable of realizing the above functions, a program process abnormality monitoring device, etc. The following takes the verification code generation device as an example to illustrate this embodiment and the following embodiments.

[0053] Based on this, the present application embodiment provides a verification code generation method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the verification code generation method of the present application.

[0054] In this embodiment, the verification code generation method includes steps S100 to S300:

[0055] Step S100, when a verification code acquisition request sent by a user terminal is detected, load parameters of each server are acquired.

[0056] In this embodiment, when a verification code acquisition request sent by a user is detected, the load of each server is first acquired. The load parameters may include the number of connections, response time, CPU usage, memory occupancy, disk I / O performance, network bandwidth occupancy, and other parameter information of each server.

[0057] In this embodiment, in order to obtain the load parameters of each server, it is necessary to ensure that monitoring tools such as Nagios, Zabbix, Cacti, etc. are deployed on all servers to collect various performance indicators of each server in real time. The load parameters of each server are collected by monitoring tools or running commands (such as top, htop, vmstat, iostat, etc.) on the server. After completing the data collection, the collected data is aggregated to a central monitoring platform or database for unified analysis and processing.

[0058] In this embodiment, when a verification code acquisition request sent by a user terminal is received, the load parameters of each server are acquired, so that the performance and resource usage of the server can be fully understood.

[0059] Step S200: determining a target server from among the servers according to the load parameters of the servers.

[0060] In this embodiment, the current load of each server is evaluated based on the collected load parameters, and based on the comprehensive evaluation results, the server with the best load condition (i.e., the lowest comprehensive load value or the highest ranking) is selected as the target server to ensure that the target server has sufficient processing power and resources to handle upcoming requests.

[0061] Please refer to Figure 2 In a feasible implementation manner, the load parameters include the number of connections and the response time. Step S200, according to the load parameters of each server, determining a target server from the servers may include steps S210 to S220:

[0062] Step S210, determining weight ratios corresponding to the number of connections and the response time, respectively, and calculating a total score of the load parameters of each of the servers, wherein the weight ratio of the number of connections is less than the weight ratio of the response time;

[0063] Step S220: determine the server corresponding to the largest total score as the target server.

[0064] It should be noted that response time refers to the time from when a user sends a request or instruction to when the server reacts (responds). The number of server connections refers to the number of concurrent connections (or sessions) that the server handles or maintains at the same time. These connections can be TCP / IP connections established between user-end devices (such as computers, smartphones, tablets, etc.) and servers for transmitting data, requesting services, or performing other network operations.

[0065] In this implementation, the weight ratios corresponding to the number of connections and response time are determined, and the total score of the load parameters of each server is calculated based on these weights, and the server corresponding to the maximum total score is used as the target server. First, the weight ratio of the number of connections and response time is determined according to business requirements or system characteristics. Secondly, for each server, the number of connections and response time data are collected. Then, the total score is calculated using the weighted sum of the number of connections and response time. The calculation formula for the total score is: total score = (Ci*Wc) + (Ri*Wr), where Wc is the weight of the number of connections, Wr is the weight of the response time, Ci is the number of connections, Ri is the sum of the response time, and i represents the server number. Finally, the total scores of all servers are compared, and the server with the highest total score is selected as the target server.

[0066] For example, there are three servers, the number of connections C1 of server 1 = 100, the response time R1 = 200 milliseconds; the number of connections C2 of server 2 = 150, the response time R2 = 150 milliseconds, the number of connections C3 of server 3 = 80, the response time R3 = 100 milliseconds, Wc = 0.4, Wr = 0.6. The total score of server 1 = (100×0.4) + (200×0.6) = 40+120 = 160; the total score of server 2 = (150×0.4) + (150×0.6) = 60+90 = 150, the total score of server 3 = (80×0.4) + (100×0.6) = 32+60 = 92. Server 1 has the highest total score, and server 1 is determined as the target server.

[0067] In another feasible implementation, the target server can also be comprehensively determined based on CPU usage, memory occupancy, disk I / O waiting time, and network bandwidth usage. A weight value is assigned according to the degree of influence of each parameter on server performance. It should be noted that the weight value can be determined based on historical data, expert opinions, or business needs. After collecting the load parameter information, the collected data is standardized. For each server, the standardized value of each load parameter is multiplied by the corresponding weight. All weighted values ​​are added together to obtain the comprehensive load value of the server. According to the calculated comprehensive load value, all servers are sorted to obtain a ranking. The server with the lowest ranking indicates that its current load situation is the best, and it is selected as the target server.

[0068] Optionally, the raw data of each load parameter is converted into a number between 0 and 1 using a minimum-maximum normalization method. First, determine the maximum and minimum values ​​of each parameter. The maximum and minimum values ​​can be set based on historical data, system specifications, or business expectations, or a set of reasonable maximum and minimum values ​​can be assumed and adjusted according to actual conditions. For each parameter X, its standardized value Xnorm is calculated by the following formula: Xnorm = (X-Xmin) / (Xmax-Xmin), where Xmin and Xmax are the minimum and maximum values ​​of parameter X, respectively. By standardizing the information of each load parameter, the problem of being unable to compare and weight due to different measurement units and ranges of different parameters is solved.

[0069] For example, assume that the original data of CPU usage is 80%, memory usage is 70%, disk I / O waiting time is 50ms, and network bandwidth usage is 20%. In the process of data standardization, the maximum value of CPU usage is 100% and the minimum value is 0%; the maximum value of memory usage is 100% and the minimum value is 0%; the maximum value of disk I / O waiting time is 100ms and the minimum value is 0ms; the maximum value of network bandwidth usage is 100% and the minimum value is 0%. Then the standardized value of CPU usage is 0.8, the standardized value of memory usage is 0.7, the standardized value of disk I / O waiting time is 0.5, and the standardized value of network bandwidth usage is 0.2. Assume that the weight of CPU usage is 0.4, the weight of memory usage is 0.3, the weight of disk I / O waiting time is 0.2, and the weight of network bandwidth usage is 0.1. The comprehensive load value = (0.8*0.4) + (0.6*0.3) + (0.3*0.2) + (0.2*0.1) = 0.32 + 0.18 + 0.06 + 0.02 = 0.58.

[0070] In this implementation, it is also possible to monitor and verify whether the evaluation results meet expectations based on actual operating conditions, and regularly adjust the weight distribution and standardization methods to ensure the accuracy and effectiveness of the evaluation results.

[0071] In this implementation, a comprehensive evaluation of the load parameters of each server is achieved, and a relatively objective and accurate comprehensive load value or ranking is obtained, which helps to select the best target server in tasks such as verification code generation and improve the overall performance of the system and user experience.

[0072] Step S300: the target server generates a target verification code according to the verification code acquisition request, and sends the target verification code to the user terminal.

[0073] In this embodiment, when receiving the verification code acquisition request sent by the user end, the server with the lowest load is selected as the target server according to the load conditions of each server. The request from the user end is received according to the load balancer (such as Nginx, HAProxy, etc.), and the request is distributed to the target server at the back end. The target server receives the HTTP request from the load balancer through a Web server (such as Apache, Nginx). After receiving the verification code acquisition request, the request parameters are parsed, and the parameters in the request may include user ID, request type, etc. Then, a unique target verification code is generated according to these parameters, and the target verification code is sent back to the user end through an HTTP response.

[0074] Please refer to Figure 2 In a feasible implementation manner, step S300, the target server generates a target verification code according to the verification code acquisition request, and sends the target verification code to the user terminal may include steps S310 to S340:

[0075] Step S310: When the target server receives the verification code acquisition request, a connection is established between the target server and the encoding module.

[0076] In this implementation, after receiving a verification code acquisition request from a user terminal (such as a Web front end or a mobile application), the target server establishes a connection with the encoding module.

[0077] In a feasible implementation manner, the step of establishing a connection between the target server and the encoding module includes:

[0078] The target server establishes a connection with the encoding module via the WebSocket protocol.

[0079] In this embodiment, a connection is established between the target server and the encoding module through the WebSocket protocol, and a library or framework that supports WebSocket is installed and configured on the target server, such as the ws library of Node.js, SpringWebFlux of Java, etc. A WebSocket server is set on the target server to listen to a specific port to wait for a connection, and a WebSocket client is set on the encoding module to connect to the WebSocket server of the target server. The WebSocket client of the encoding module requests to establish a WebSocket connection by sending an HTTP Upgrade request to the WebSocket server of the target server. After receiving the Upgrade request, if the target server agrees to establish a connection, it will send an HTTP 101 Switching Protocols response, indicating that the connection has been successfully upgraded to a WebSocket connection.

[0080] In this implementation, by establishing a connection between the server and the encoding module of the server through the WebSocket protocol, efficient, real-time and stable data exchange can be achieved, thereby improving the overall performance of the system and user experience.

[0081] In another feasible implementation, a connection can be established between the target server and the encoding module through an internal network call, such as RPC (Remote Procedure Call), REST API (Representational State Transfer Application Programming Interface), etc.

[0082] Step S320: the target server generates a first verification code according to the verification code acquisition request, and sends the first verification code to the encoding module.

[0083] Step S330, determining a preset encoding rule according to the encoding module, performing serial number arrangement and feature arrangement on the first verification code according to the preset encoding rule to generate the target verification code, and sending the target verification code to the target server.

[0084] Step S340: sending the target verification code to the user terminal according to the target server.

[0085] It should be noted that serial number arrangement refers to assigning a unique serial number or timestamp to the SMS verification code. Feature arrangement refers to adding specific identification features to the verification code content, format or sending method.

[0086] In this embodiment, first, the target server generates a first verification code according to the parameters in the request (such as user ID, request timestamp, etc.), and the first verification code can be a simple random string or digital sequence. Secondly, the target server sends the generated first verification code to the encoding module. After the encoding module receives the first verification code, it processes it according to the preset encoding rules. When performing serial number arrangement, a serial number can be added to the first verification code according to a certain logical timestamp or request ID to ensure the uniqueness of the verification code. When performing feature arrangement, the appearance of the verification code can be changed by adding specific characters, numbers or symbols to increase its complexity and security. When performing feature arrangement, the corresponding service provider can also be used as a keyword. After the encoding module completes the serial number arrangement and feature arrangement, it generates the final target verification code and sends the target verification code to the target server. After the target server receives the target verification code, it encapsulates it in the HTTP response and returns it to the user end.

[0087] In this embodiment, in the encoding module, the first verification code can be serialized and characterized using the json format. The json module provides a series of functions for processing JSON data, including converting Python objects into strings in JSON format and parsing strings in JSON format into Python objects.

[0088] For example, the specific encoding process is as follows:

[0089] Python

[0090] data = {

[0091] "feature_1":value1,

[0092] "feature_2":value2;

[0093] };

[0094] Among them, feature_1 is a key, and the corresponding value is value1; feature_1 is another key, and the corresponding value is value2; value1 and value2 are variables, representing the specific parameters of serial number arrangement and feature arrangement respectively.

[0095] For example, the target server generates a random 6-digit number as the first verification code: "123456", and sends "123456" to the encoding module through an internal API call. The preset encoding rule is to add the first two digits of the hash value of the user ID to the end of the verification code and replace the third character with "#". When the first two digits of the hash value of the user ID are "AB", the encoding module processes "123456" as "1#3AB6".

[0096] In this embodiment, the first verification code is arranged according to a preset coding rule, and each verification code is accompanied by a unique serial number and feature information, which can distinguish different verification code instances. In addition, through serial number arrangement, the generation, sending, and verification process of each verification code can be easily tracked, which is convenient for problem troubleshooting and auditing. Through feature arrangement, adding specific features to the content or format of the verification code can increase the difficulty of cracking and improve the security protection capability of the system.

[0097] Please refer to Figure 3 In a feasible implementation manner, determining the preset encoding rule according to the encoding module in step S330 may include steps S331 to S333:

[0098] Step S331, obtaining a historical target verification code according to the encoding module, and determining a sequence arrangement rule and a feature arrangement rule according to the historical target verification code.

[0099] In this embodiment, all sent and received historical verification codes and related information are obtained according to the encoding module, including but not limited to the verification code content, sending time, receiving status, service provider identification, etc. After obtaining the historical target verification code and its related information, the data is cleaned to remove invalid or duplicate records to ensure the accuracy and consistency of the data. In the obtained historical target verification code, the verification code content is segmented according to possible formats, such as separating the serial number, features (such as service provider keywords) and random characters to determine the serial number arrangement rules and feature arrangement rules.

[0100] Optionally, when determining the serial number arrangement rule, a regular expression, pattern matching or machine learning algorithm can be used to extract the serial number part from the verification code content, and the pattern of the serial number part, such as an increasing sequence, a timestamp, etc., can be analyzed to determine the serial number arrangement rule. Finally, a portion of historical data is used to verify the correctness of the extracted serial number arrangement rule.

[0101] Optionally, when determining the feature arrangement rules, keyword extraction is first performed to extract feature information from the verification code content, such as keywords used as service provider identification. Secondly, specific keyword lists or regular expressions are defined for different service providers to match the verification codes they send. Finally, the accuracy of keyword matching is tested using historical data, and the keyword list is adjusted to improve the accuracy.

[0102] Step S332, respectively adjusting the parameters of the sequence number arrangement rule and the feature arrangement rule.

[0103] Step S333: Determine the sequence number arrangement rule and the feature arrangement rule after parameter adjustment as the preset coding rule.

[0104] In this implementation, according to actual usage and by learning the rules in the historical target verification code, the parameters of the sequence number arrangement rules and feature arrangement rules are adjusted, and the parameters of the sequence number arrangement rules and feature arrangement rules are adjusted, such as modifying the starting value of the sequence number generation, the increment step, or optimizing the keyword list, etc. The adjusted sequence number arrangement rules and feature arrangement rules are determined as preset coding rules. And the determined preset coding rules are integrated into the verification code generation and verification process of the system.

[0105] In this implementation, by determining the encoding rules from the historical target verification codes and adjusting the rules in real time, the verification codes can be effectively prevented from being maliciously cracked or abused, and the verification efficiency and accuracy of the verification codes can be improved, thereby improving the user experience.

[0106] In this embodiment, after detecting the verification code acquisition request sent by the user end, the load parameters of each server are obtained, and the server generating the verification code is determined according to the load parameters. By assigning the verification code generation task to the server with the lowest load, the user's waiting time can be reduced, the system's response speed can be increased, and the user experience can be improved. In addition, it can also ensure that all servers in the system can be reasonably utilized, avoiding some servers from being overloaded due to processing too many requests, while other servers are idle.

[0107] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 4 After step S300, the verification code generation method further includes steps A100 to A200:

[0108] Step A100, obtaining the sending time of the target verification code, and associating the target verification code with the sending time;

[0109] Step A200, storing the associated target verification code.

[0110] In this embodiment, when the user sends a verification code acquisition request, the current timestamp (or a formatted date and time string) is recorded, and the timestamp is used as the sending time of the target verification code. After the sending time is determined, the verification code is associated with the sending time, and a record is created for the verification code in the database. The record contains at least the target verification code and the sending time. The generated verification code and the corresponding sending time are written into the record to achieve their association. The record containing the verification code and the sending time is saved in the database.

[0111] Optionally, the number of uses of the target verification code can be set to prevent the verification code from being maliciously used, thereby improving the security of the system.

[0112] In this embodiment, by associating the target verification code with the sending time, it is possible to check whether the verification code is within the validity period during verification, thereby preventing the use of an expired verification code for verification.

[0113] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 4 After step A200, the verification code generation method further includes steps A300 to A400:

[0114] Step A300, when obtaining the verification request sent by the user terminal, parsing the verification request to obtain a second verification code;

[0115] Step A400, obtaining the associated target verification code, and determining whether verification is successful based on the target verification code and the second verification code.

[0116] It should be noted that the second verification code is a verification code sent by the user via SMS, email or other channels, received by the verification code generating device of this application, and entered by the user.

[0117] In this embodiment, after the user receives the target verification code, a verification request is sent to the server according to the target verification code. When the user initiates a verification request, the request usually contains some necessary information, such as a user identifier (such as a user name, mobile phone number, email address, etc.), a request type (clearly a verification code verification request), a possible request timestamp, and a possible security token (such as a CSRF token). The server receives and parses the verification request, and extracts the second verification code sent by the user from the request. Secondly, the server queries the database or cache system according to the user identifier, request type or other identifiers (such as the unique ID of the request) to obtain the stored target verification code. Finally, it is determined whether the verification is passed based on the target verification code and the second verification code.

[0118] In this embodiment, by verifying the target verification code and the second verification code, the security, validity and accuracy of the verification code can be ensured to prevent unauthorized access and operation.

[0119] Please refer to Figure 5 In a feasible implementation manner, step A400, obtaining the associated target verification code, and determining whether the verification is passed according to the target verification code and the second verification code may include steps A410 to A440:

[0120] Step A410, determining the validity time according to the sending time of the target verification code;

[0121] Step A420, determining whether the reception time of the second verification code is within the valid time, and determining whether the target verification code and the second verification code are the same;

[0122] Step A430, if the target verification code is the same as the second verification code, and the receiving time of the second verification code is within the valid time, then it is determined that the verification is passed;

[0123] Step A440: If the target verification code and the second verification code are not the same, and / or the reception time of the second verification code is not within the valid time, the verification fails, and an error prompt is sent to the user terminal.

[0124] In this embodiment, after obtaining the target verification code and the second verification code, first, directly compare whether the second verification code and the target verification code are consistent. Secondly, check whether the second verification code is still within the validity period. When the second verification code and the target verification code are consistent and the second verification code is within the validity period, the verification is passed. After the verification is passed, the user's status can be updated (such as marked as verified), and the verification result and time and other information can be recorded. When there is any one of the following situations: the second verification code and the target verification code are inconsistent, and the second verification code is not within the validity period, the verification fails, and the server returns a corresponding error message to the user end; information such as the cause and number of failures can also be recorded for subsequent analysis and processing.

[0125] In another feasible implementation, the number of times the verification code is used can also be verified. During the verification process, the number of times each mobile phone number or account can request a verification code within a certain period of time (such as one day) is determined. When the number of verification code requests reaches the limit, a clear prompt message is given to inform the user that the upper limit of today's requests has been reached, and it is recommended to try again later or contact customer service. For requests that exceed the number limit, an error code or error message is returned to ensure that too many system resources are not consumed due to malicious requests. By verifying the number of uses, malicious users can be effectively prevented from frequently requesting verification codes to perform brute force cracking, malicious registration or login, etc., reduce invalid or malicious verification code requests, and reduce the load pressure on the server.

[0126] The present application provides a verification code generation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the verification code generation method in the above-mentioned embodiment 1.

[0127] Reference below Figure 6 , which shows a schematic diagram of the structure of a verification code generating device suitable for implementing the embodiment of the present application. The verification code generating device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, servers, server clusters, etc. Figure 6 The verification code generating device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0128] like Figure 6 As shown, the verification code generating device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the verification code generating device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the verification code generation device to communicate with other devices wirelessly or by wire to exchange data. Although the verification code generation device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided alternatively.

[0129] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0130] The verification code generation device provided by the present application adopts the verification code generation method in the above embodiment, which can solve the technical problem of how to improve the generation efficiency of the verification code and avoid the user end not receiving the verification code within the valid time. Compared with the prior art, the beneficial effects of the verification code generation device provided by the present application are the same as the beneficial effects of the verification code generation method provided by the above embodiment, and the other technical features in the verification code generation device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0131] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0132] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0133] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the verification code generation method in the above-mentioned embodiment.

[0134] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0135] The computer-readable storage medium may be included in the verification code generating device; or may exist independently without being assembled into the verification code generating device.

[0136] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the verification code generating device, the verification code generating device: when detecting a verification code acquisition request sent by the user terminal, obtains the load parameters of each server; according to the load parameters of each server, determines a target server among the servers; the target server generates a target verification code according to the verification code acquisition request, and sends the target verification code to the user terminal.

[0137] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0138] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0139] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0140] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned verification code generation method, and can solve the technical problem of how to improve the generation efficiency of the verification code and avoid the user end not receiving the verification code within the effective time. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the verification code generation method provided by the above-mentioned embodiment, and will not be repeated here.

[0141] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A verification code generation method, characterized in that: The method comprises: When a verification code acquisition request sent by a user is detected, load parameters of each server are acquired; Determining a target server from among the servers according to the load parameters of the servers; The target server generates a target verification code according to the verification code acquisition request, and sends the target verification code to the user terminal.

2. The method according to claim 1, characterized in that The load parameters include the number of connections and the response time; the step of determining a target server from among the servers according to the load parameters of the servers includes: Determine the weight ratios corresponding to the number of connections and the response time, respectively, and calculate the total score of the load parameters of each of the servers, wherein the weight ratio of the number of connections is less than the weight ratio of the response time; The server corresponding to the largest total score is determined as the target server.

3. The method according to claim 1, characterized in that The step of the target server generating a target verification code according to the verification code acquisition request and sending the target verification code to the user terminal includes: When the target server receives the verification code acquisition request, a connection is established between the target server and the encoding module; The target server generates a first verification code according to the verification code acquisition request, and sends the first verification code to the encoding module; Determine a preset encoding rule according to the encoding module, perform sequence number arrangement and feature arrangement on the first verification code according to the preset encoding rule to generate the target verification code, and send the target verification code to the target server; The target verification code is sent to the user terminal according to the target server.

4. The method according to claim 3, characterized in that The step of determining a preset encoding rule according to the encoding module comprises: Acquire a historical target verification code according to the encoding module, and determine a sequence number arrangement rule and a feature arrangement rule according to the historical target verification code; respectively adjusting the parameters of the sequence number arrangement rule and the feature arrangement rule; The serial number arrangement rule and the feature arrangement rule after parameter adjustment are determined as the preset coding rule.

5. The method according to claim 3, characterized in that The step of establishing a connection between the target server and the encoding module comprises: The target server establishes a connection with the encoding module via the WebSocket protocol.

6. The method according to claim 3, characterized in that After the step of sending the target verification code to the user terminal according to the target server, the method further includes: Acquire the sending time of the target verification code, and associate the target verification code with the sending time; The associated target verification code is stored.

7. The method according to claim 6, characterized in that The method further comprises: When the verification request sent by the user terminal is obtained, the verification request is parsed to obtain a second verification code; The associated target verification code is obtained, and whether the verification is successful is determined according to the target verification code and the second verification code.

8. The method according to claim 7, characterized in that The step of determining whether verification is passed according to the target verification code and the second verification code comprises: Determining the validity time according to the sending time of the target verification code; Determining whether the reception time of the second verification code is within the valid time, and determining whether the target verification code and the second verification code are the same; If the target verification code is the same as the second verification code, and the receiving time of the second verification code is within the valid time, it is determined that the verification is passed; If the target verification code and the second verification code are different, and / or the reception time of the second verification code is not within the valid time, the verification fails, and an error prompt is sent to the user terminal.

9. A verification code generating device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the verification code generation method according to any one of claims 1 to 8.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the verification code generation method according to any one of claims 1 to 8 are implemented.