Random code generation method, device, equipment and storage medium

By using a random code generation method with three data pools, the problems of low efficiency and slow deduplication speed in the existing technology are solved, and stable and efficient random code generation is achieved in high-concurrency scenarios.

CN116301722BActive Publication Date: 2025-09-30SOUNDAI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211735153.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-30
Publication Date
2025-09-30
Estimated Expiration
2042-12-30

AI Technical Summary

Technical Problem

Existing technologies are inefficient in generating random codes, which can easily lead to response blocking, especially in high-concurrency scenarios, and have a slow deduplication speed, affecting response efficiency.

Method used

A three-data pool solution is adopted: the second data pool stores available non-repetitive random codes, and the third data pool stores used random codes. The concurrency security issues in high-concurrency scenarios are solved by the union pool, and the data volume is kept reasonable through regular cleaning.

Benefits of technology

It significantly improves the response efficiency of random codes, avoids response blocking and slow deduplication in high-concurrency scenarios, and provides a stable random code generation solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116301722B_ABST
    Figure CN116301722B_ABST
Patent Text Reader

Abstract

The present application discloses a random code generation method, device, equipment and storage medium, which belongs to the field of security verification technology. The present application can greatly improve the response efficiency of random codes. In detail, the present application provides three data pools, namely the first data pool, the second data pool and the third data pool, wherein the first data pool is the union of the second data pool and the third data pool; the second data pool is used to store available random codes, and any two available random codes are not repeated; the third data pool is used to store random codes taken out from the second data pool and used; for non-high concurrency scenarios, when using random codes, they can be directly obtained from the second data pool, avoiding the problem of response blocking caused by low generation efficiency when generating random codes on-the-go; in addition, the newly generated random codes need to be deduplicated based on the second data pool before being added to the first data pool and the second data pool, thus avoiding the problem of slow deduplication speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Currently, many businesses use random codes for security verification. Random codes are randomly generated and can be composed of random numbers and uppercase and lowercase English letters.

[0003] In particular, for certain businesses, it is also necessary to ensure that the generated random codes are not repeated, such as registration codes, invitation codes, redemption codes, store codes, or product codes. For example, after receiving a random code acquisition request, the relevant technology usually first uses a specific code to generate a random code, and then determines whether the currently generated random code is repeated based on the generated random codes stored in the database; if not, the currently generated random code is issued.

[0004] However, the above-mentioned method of generating random codes on demand is inefficient. For example, in high-concurrency scenarios, this method of generating random codes when needed can easily cause response blocking due to low generation efficiency. In addition, the above-mentioned method of deduplicating random codes is slow. That is, as more and more random codes are stored in the database, the speed of determining whether the currently generated random code is repeated based on the database will become slower and slower, ultimately affecting response efficiency. Summary of the Invention

[0005] The embodiments of the present application provide a random code generation method, apparatus, device, and storage medium, which greatly improves response efficiency. The technical solution is as follows:

[0006] In one aspect, a method for generating a random code is provided, the method comprising:

[0007] Generate a new random code based on the candidate characters;

[0008] Perform deduplication verification on newly generated random codes based on the first data pool; wherein the first data pool is the union of the second data pool and the third data pool; the second data pool is used to store available random codes, and any two available random codes are unique; and the third data pool is used to store used random codes taken from the second data pool;

[0009] In response to the newly generated random code passing the deduplication check, adding the newly generated random code to the first data pool and the second data pool respectively;

[0010] Receive a random code acquisition request;

[0011] In response to the number of the random code acquisition requests being no greater than the number of random codes currently stored in the second data pool, a random code is randomly selected from the second data pool, and the selected random code is issued.

[0012] In a possible implementation, the method further includes:

[0013] In response to the number of random code acquisition requests being greater than the number of random codes currently stored in the second data pool, issuing the random codes currently stored in the second data pool; and

[0014] Determine a first quantity based on the number of random code acquisition requests and the number of random codes currently stored in the second data pool; generate the first quantity of random codes based on the candidate characters; and issue the first quantity of random codes in response to the first quantity of random codes passing the deduplication check.

[0015] In a possible implementation, the second data pool is used to store a second number of available random codes; and the method further includes:

[0016] Periodically deleting part of the random codes stored in the third data pool, and deleting the part of the random codes stored in the first data pool together;

[0017] The random codes that have not been deleted in the third data pool are a third number of random codes that have been recently taken out from the second data pool and used; and the second number is greater than the third number.

[0018] In a possible implementation, in response to the newly generated random code passing the deduplication check, adding the newly generated random code to the first data pool and the second data pool respectively includes:

[0019] In response to the newly generated random code not existing in the first data pool, it is determined that the newly generated random code passes the deduplication check, and the newly generated random code is added to the first data pool and the second data pool respectively.

[0020] In a possible implementation, generating a new random code based on the candidate characters includes:

[0021] Determining a composition form of the random code, and constructing a character array according to the composition form of the random code;

[0022] Deleting specific characters from the character array to obtain the candidate characters; wherein the specific characters include at least one set of easily confused character pairs;

[0023] A random character string of specified digits is newly generated based on the candidate characters to obtain the random code.

[0024] In another aspect, a random code generating device is provided, the device comprising:

[0025] A generating module is configured to generate a new random code based on the candidate characters;

[0026] A verification module is configured to perform deduplication verification on newly generated random codes based on a first data pool; wherein the first data pool is the union of a second data pool and a third data pool; the second data pool is used to store available random codes, and any two available random codes are unique; and the third data pool is used to store used random codes taken from the second data pool;

[0027] a storage module configured to, in response to the newly generated random code passing the deduplication check, add the newly generated random code to the first data pool and the second data pool respectively;

[0028] The processing module is configured to receive a random code acquisition request; in response to the number of the random code acquisition requests being no greater than the number of random codes currently stored in the second data pool, randomly select a random code from the second data pool, and issue the selected random code.

[0029] In a possible implementation, the processing module is further configured to:

[0030] In response to the number of random code acquisition requests being greater than the number of random codes currently stored in the second data pool, issuing the random codes currently stored in the second data pool; and

[0031] Determine a first quantity based on the number of random code acquisition requests and the number of random codes currently stored in the second data pool; generate the first quantity of random codes based on the candidate characters; and issue the first quantity of random codes in response to the first quantity of random codes passing the deduplication check.

[0032] In a possible implementation, the second data pool is used to store a second number of available random codes; and the apparatus further includes:

[0033] a deleting module configured to periodically delete part of the random codes stored in the third data pool and also delete the part of the random codes stored in the first data pool;

[0034] The random codes that have not been deleted in the third data pool are a third number of random codes that have been recently taken out from the second data pool and used; and the second number is greater than the third number.

[0035] In a possible implementation, the storage module is configured to:

[0036] In response to the newly generated random code not existing in the first data pool, it is determined that the newly generated random code passes the deduplication check, and the newly generated random code is added to the first data pool and the second data pool respectively.

[0037] In a possible implementation, the generating module is configured to:

[0038] Determining a composition form of the random code, and constructing a character array according to the composition form of the random code;

[0039] Deleting specific characters from the character array to obtain the candidate characters; wherein the specific characters include at least one set of easily confused character pairs;

[0040] A random character string of specified digits is newly generated based on the candidate characters to obtain the random code.

[0041] On the other hand, a computer device is provided, comprising a processor and a memory, wherein the memory stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the above-mentioned random code generation method.

[0042] On the other hand, a computer-readable storage medium is provided, wherein at least one program code is stored in the storage medium, and the at least one program code is loaded and executed by a processor to implement the above-mentioned random code generation method.

[0043] On the other hand, a computer program product or computer program is provided, which includes computer program code, the computer program code being stored in a computer-readable storage medium, the processor of a computer device reading the computer program code from the computer-readable storage medium, and the processor executing the computer program code, so that the computer device performs the above-mentioned random code generation method.

[0044] The random code generation scheme provided by the embodiment of the present application can greatly improve the response efficiency of the random code and provide a good user experience. In detail, the embodiment of the present application provides three data pools, namely the first data pool, the second data pool and the third data pool, wherein the first data pool is the union of the second data pool and the third data pool; the second data pool is used to store available random codes, and any two available random codes are not repeated; the third data pool is used to store random codes taken out from the second data pool and used; for non-high concurrency scenarios, when using random codes, they can be directly obtained from the second data pool, avoiding the problem of response blocking caused by low generation efficiency when generating random codes on-the-fly; in addition, the newly generated random code needs to be deduplicated based on the second data pool before being added to the first data pool and the second data pool, thus avoiding the problem of slow deduplication speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0046] Figure 1 Schematic diagram of an implementation environment involved in a random code generation method provided in an embodiment of the present application;

[0047] Figure 2 This is a schematic diagram of the structure of a random code generating device provided in an embodiment of the present application;

[0048] Figure 3 This is a flow chart of a random code generation method provided in an embodiment of the present application;

[0049] Figure 4 This is a flow chart of a random code generation method provided in an embodiment of the present application;

[0050] Figure 5 This is a schematic diagram of the structure of a random code generating device provided in an embodiment of the present application;

[0051] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0052] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0053] In this application, the terms "first," "second," and the like are used to distinguish identical or similar items having substantially the same role and function. It should be understood that "first," "second," and "nth" do not have a logical or temporal dependency, nor do they limit the quantity or execution order. It should also be understood that although the following description uses the terms "first," "second," and the like to describe various elements, these elements should not be limited by these terms.

[0054] These terms are simply used to distinguish one element from another. For example, a first element can be referred to as a second element, and similarly, a second element can be referred to as a first element, without departing from the scope of various examples. Both the first element and the second element can be elements, and in some cases, can be separate and different elements.

[0055] Here, at least one refers to one or more than one. For example, at least one element can be one element, two elements, three elements, or any other integer greater than or equal to one. And multiple refers to two or more than two. For example, multiple elements can be two elements, three elements, or any other integer greater than or equal to two.

[0056] The term "and / or" used in this document indicates that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.

[0057] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.

[0058] The following introduces the implementation environment involved in the random code generation method provided in the embodiment of the present application.

[0059] Figure 1 This is a schematic diagram of the implementation environment involved in a random code generation method provided in an embodiment of the present application. Figure 1 The implementation environment includes: a random code acquisition device 101 on the user side and a random code generation device 102 on the network side.

[0060] Exemplarily, the random code acquisition device 101 is a terminal, and the random code generation device 102 is a server. The terminal is a computer device with machine learning capabilities, such as a smartphone used by a user. The server can be an independent physical server, or a server cluster or distributed system consisting of multiple physical servers, which is not limited in this application. The random code generation device 102 is connected to the random code acquisition device 101 via a wireless network. Furthermore, the server involved in the embodiments of the present application may also include other servers to provide more comprehensive and diverse services.

[0061] In the embodiment of the present application, the random code acquisition device 101 is used to send a random code acquisition request to the random code generation device 102, and the random code generation device 102 is used to generate a random code after receiving the random code acquisition request and send it to the random code acquisition device 101.

[0062] In addition, those skilled in the art will appreciate that the number of random code acquisition devices 101 may be more or less than that shown in the figure. For example, the number of random code acquisition devices may be only a few, or the number of random code acquisition devices may be dozens, hundreds, or even more, and this embodiment of the application does not limit this.

[0063] For example, the random code generation method mentioned in the embodiment of the present application can be applied to a variety of businesses, and the generated random codes include but are not limited to registration codes, invitation codes, redemption codes, store codes or product codes, etc.

[0064] The random code generation method provided in the embodiment of the present application can be applied to payment services, transfer services, exchange services, etc., and this application does not limit this.

[0065] Figure 2 Schematic diagram of the structure of a random code generating device provided in an embodiment of the present application.

[0066] See also Figure 2 The device includes a Redis component and a task component. The Redis component includes an available pool, a used pool, and a union pool; the task component includes the addjob function and the deljob function. For example, the available pool and the union pool are of the Set type, and the used pool is of the List type.

[0067] The Set-type available pool is used to store M non-repeating random codes. When a random code is needed and the concurrency is low, a Redis-based sPop command is all that's needed to randomly pop an available random code from the available pool. The List-type used pool is used to store the most recently used N random codes taken from the available pool. The Set-type union pool is the union of the available pool and the used pool. That is, the union pool stores all available and used random codes, primarily addressing concurrency safety issues caused by the window period in high-concurrency scenarios.

[0068] For example, the value of M is 10000 and the value of N is 2000, which is not limited in this application.

[0069] Among them, the addjob function is used to generate a random code and perform deduplication verification. After passing the deduplication verification, the newly generated random code is stored in the available pool and the union pool.

[0070] The deljob function is used to regularly clean up the random codes stored in the used pool and the union pool. For example, it ensures that the number of random codes stored in the used pool is only 2000 to prevent Redis from storing too much data. In other words, the deljob function needs to be started regularly to delete all data in the used pool except the N most recently used random codes, and also delete these random codes stored in the union pool.

[0071] In addition, when a random code is needed and the concurrency is too large, for example, the addjob function can no longer guarantee that there are enough random codes stored in the available pool, then the random code will be generated immediately and used directly after passing the deduplication check.

[0072] In summary, the present embodiment utilizes Redis, addjob, and deljob components to implement a random code generation solution that is out-of-order, non-duplicate, highly concurrent, stable, and highly available. Specifically, addjob, deljob, and Redis improve the response efficiency of random codes. Furthermore, Redis's three data pools address the slow deduplication speed issues inherent in related technologies. Furthermore, the introduction of the union pool addresses concurrency safety issues during high-concurrency window periods.

[0073] Figure 3 This is a flow chart of a random code generation method provided by an embodiment of the present application. The execution subject of this method is a computer device, such as Figure 1 The random code generating device shown. Figure 3 , the method process provided in the embodiment of the present application includes:

[0074] 301. Generate a new random code based on the candidate characters.

[0075] This step is performed by Figure 2 The addjob function shown is executed, that is, the addjob function is used to generate a random code.

[0076] In a possible implementation, a new random code is generated based on the candidate characters, including but not limited to the following methods:

[0077] 3011. Determine the composition form of the random code, construct a character array based on the composition form of the random code, and delete specific characters in the character array to obtain candidate characters.

[0078] Exemplarily, the random code may be composed of at least one of numbers, uppercase and lowercase letters, and special characters. For example, the random code may be composed of numbers and uppercase and lowercase letters. Furthermore, the special characters may be underscores, asterisks, slashes, etc., which are not limited in this application.

[0079] Taking the random code as an example, which is composed of numbers and uppercase and lowercase letters, an array (referred to as a character array in this article) is composed of numbers 0-9, lowercase letters az, and uppercase letters AZ.

[0080] In addition, the specific characters include at least one group of easily confused character pairs, such as the letter o and the number 0, the uppercase letter I and the lowercase letter l, which is not limited in this application.

[0081] 3012. Generate a random string of specified digits based on the candidate characters to obtain a random code.

[0082] Among them, the number of bits of the random code can be set as needed, for example, the number of bits of the random code is set to a fixed value, which is referred to as the specified number of bits in this article; or, the number of bits of the random code can also be in a numerical range, such as 8-12 bits, which is not limited in this application.

[0083] In another possible implementation, the embodiment of the present application is based on thread pool + redis concurrent lock

[0084] +CountDownLatch to ensure that the random code filling operation of the available pool is not repeated.

[0085] Among them, the threads in the thread pool are used to generate random codes; the redis concurrent lock is applied in a concurrent environment; for example, a String type value lock can be used as a specific representation of the redis concurrent lock. When lock exists, it means it is in a locked state; when lock does not exist, it means it is in an unlocked state. When constructing CountDownLatch, an integer n needs to be passed in. Before this integer "counts down" to 0, the main thread needs to wait, and this "countdown" process is driven by each execution thread. Each thread "counts down" once after completing a task. In summary, the role of CountDownLatch is to wait for other threads to complete their tasks. If necessary, the execution results of each task can be summarized, and then the main thread can continue to execute.

[0086] 302. Perform deduplication verification on the newly generated random codes based on the first data pool; wherein the first data pool is the union of the second data pool and the third data pool; the second data pool is used to store available random codes, and any two available random codes are unique; and the third data pool is used to store used random codes taken from the second data pool.

[0087] This step is performed by Figure 2 The addjob function shown is executed, that is, the addjob function is used to perform deduplication verification.

[0088] It should be noted that the first data pool mentioned above refers to Figure 2 The second data pool refers to the union pool of Figure 2 The available pool in the third data pool refers to Figure 2 The used pool in the . For example, a Set-type available pool is used to store M unique available random codes. When needed, a random code can be randomly popped from the available pool using the Redis sPop command. The List-type used pool is used to store the most recently used N random codes taken from the available pool. M is also referred to herein as the second number, and N is also referred to herein as the third number. The second number is greater than the third number.

[0089] Deduplication check is also called duplicate check. In one possible implementation, based on the first data pool, deduplication check is performed on the newly generated random code, including but not limited to the following methods: querying whether the newly generated random code exists in the union pool; in response to the newly generated random code not existing in the union pool, determining that the newly generated random code passes the deduplication check and is considered non-duplicate; in response to the newly generated random code existing in the union pool, determining that the newly generated random code fails the deduplication check and is considered duplicate.

[0090] To sum up, deduplication verification is to query the union pool to see whether there is a newly generated random code.

[0091] 303 . In response to the newly generated random code passing the deduplication check, add the newly generated random code to the first data pool and the second data pool respectively.

[0092] Steps 302-303 are also called data pre-warming steps. After the addJob function generates a new random code, a deduplication check is performed. If the newly generated random code passes the check, it is considered non-duplicate and is stored in the available pool and the union pool respectively.

[0093] 304. Receive a random code acquisition request; in response to the number of random code acquisition requests being no greater than the number of random codes currently stored in the second data pool, randomly select a random code from the second data pool and issue the selected random code.

[0094] In the embodiments of the present application, the occasions where a random code is required are generally when the user side requests to complete security verification by filling in a random code. Therefore, for non-high concurrency scenarios, that is, the number of random code acquisition requests is not greater than the number of random codes currently stored in the available pool, then the network side can directly randomly select a random code from the available pool after receiving the random code acquisition request and issue the selected random code.

[0095] It should be noted that for high-concurrency scenarios, if a large number of users request random codes in a short period of time, resulting in excessive concurrency, for example, the random codes currently stored in the available pool are no longer able to cope with this concurrency problem, then a slow response problem may occur. To address this issue, the embodiment of the present application implements thread-safe support for the window period of high-concurrency scenarios through a pooled pool, avoiding the concurrency safety issues existing in related technologies. Exemplarily, the concurrency safety issue refers to the situation where thread A generates a random code aa that has not yet been stored in the library, and thread B generates another random code aa and finds that the random code is not currently stored in the library. The random codes aa generated by the two threads will eventually be stored in the library, resulting in random code duplication.

[0096] 305. Receive a random code acquisition request; in response to the number of random code acquisition requests being greater than the number of random codes currently stored in the second data pool, issue the random codes currently stored in the second data pool; and, based on the number of random code acquisition requests and the number of random codes currently stored in the second data pool, determine a first number; generate a first number of random codes based on the candidate characters; and in response to the first number of random codes passing a deduplication check, issue the first number of random codes.

[0097] Exemplarily, the first number is the difference between the number of random code acquisition requests and the number of random codes currently stored in the second data pool, which is not limited in this application.

[0098] In another possible implementation, this embodiment of the present application also periodically initiates the deljob function to periodically clear the random codes stored in the used pool and the union pool. In other words, this embodiment of the present application also includes periodically deleting a portion of the random codes stored in the third data pool and also deleting the portion of random codes stored in the first data pool. The random codes that are not deleted from the third data pool are the third number of random codes that were recently extracted and used from the second data pool.

[0099] The random code generation scheme provided by the embodiment of the present application can greatly improve the response efficiency of the random code and provide a good user experience. In detail, the embodiment of the present application provides three data pools, namely the union pool, the available pool and the used pool, wherein the union pool is the union of the available pool and the used pool; the available pool is used to store available random codes, and any two available random codes are not repeated; the used pool is used to store random codes taken out of the available pool and used; for non-high concurrency scenarios, when using random codes, they can be obtained directly from the available pool, avoiding the problem of response blocking caused by low generation efficiency when generating random codes on-the-fly; in addition, the newly generated random code needs to be deduplicated based on the available pool before being added to the union pool and the available pool, thus avoiding the problem of slow deduplication speed.

[0100] In addition, by regularly clearing the random codes stored in the used pool and the union pool, Redis can avoid excessive data storage. In addition, for high-concurrency scenarios, the union pool can avoid concurrency security issues during the high-concurrency window period.

[0101] In summary, the embodiments of the present application implement a random code generation solution that is out of order, non-repetitive, highly concurrent, stable, and highly available.

[0102] Figure 5 This is a schematic diagram of the structure of a random code generating device provided by an embodiment of the present application. Figure 5 , the device comprises:

[0103] The generating module 501 is configured to generate a new random code according to the candidate characters;

[0104] Verification module 502 is configured to perform deduplication verification on newly generated random codes based on a first data pool; wherein the first data pool is the union of a second data pool and a third data pool; the second data pool is used to store available random codes, and any two available random codes are unique; and the third data pool is used to store used random codes taken from the second data pool.

[0105] The storage module 503 is configured to add the newly generated random code to the first data pool and the second data pool respectively in response to the newly generated random code passing the deduplication check;

[0106] The processing module 504 is configured to receive a random code acquisition request; in response to the number of the random code acquisition request being no greater than the number of random codes currently stored in the second data pool, randomly select a random code from the second data pool, and issue the selected random code.

[0107] The random code generation scheme provided by the embodiment of the present application can greatly improve the response efficiency of the random code and provide a good user experience. In detail, the embodiment of the present application provides three data pools, namely the first data pool, the second data pool and the third data pool, wherein the first data pool is the union of the second data pool and the third data pool; the second data pool is used to store available random codes, and any two available random codes are not repeated; the third data pool is used to store random codes taken out from the second data pool and used; for non-high concurrency scenarios, when using random codes, they can be directly obtained from the second data pool, avoiding the problem of response blocking caused by low generation efficiency when generating random codes on-the-fly; in addition, the newly generated random code needs to be deduplicated based on the second data pool before being added to the first data pool and the second data pool, thus avoiding the problem of slow deduplication speed.

[0108] In a possible implementation, the processing module is further configured to:

[0109] In response to the number of random code acquisition requests being greater than the number of random codes currently stored in the second data pool, issuing the random codes currently stored in the second data pool; and

[0110] Determine a first quantity based on the number of random code acquisition requests and the number of random codes currently stored in the second data pool; generate the first quantity of random codes based on the candidate characters; and issue the first quantity of random codes in response to the first quantity of random codes passing the deduplication check.

[0111] In a possible implementation, the second data pool is used to store a second number of available random codes; and the apparatus further includes:

[0112] a deleting module configured to periodically delete part of the random codes stored in the third data pool and also delete the part of the random codes stored in the first data pool;

[0113] The random codes that have not been deleted in the third data pool are a third number of random codes that have been recently taken out from the second data pool and used; and the second number is greater than the third number.

[0114] In a possible implementation, the storage module is configured to:

[0115] In response to the newly generated random code not existing in the first data pool, it is determined that the newly generated random code passes the deduplication check, and the newly generated random code is added to the first data pool and the second data pool respectively.

[0116] In a possible implementation, the generating module is configured to:

[0117] Determining a composition form of the random code, and constructing a character array according to the composition form of the random code;

[0118] Deleting specific characters from the character array to obtain the candidate characters; wherein the specific characters include at least one set of easily confused character pairs;

[0119] A random character string of specified digits is newly generated based on the candidate characters to obtain the random code.

[0120] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present disclosure, and will not be described in detail here.

[0121] It should be noted that the random code generation device provided in the above embodiment only uses the division of the above functional modules as an example to illustrate the generation of random codes. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the random code generation device provided in the above embodiment and the random code generation method embodiment are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0122] Figure 6 : It is a structural diagram of a computer device 600 provided in an embodiment of the present application. The computer 600 can be a server. The computer device 600 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 601 and one or more memories 602, wherein at least one program code is stored in the memory 602, and the at least one program code is loaded and executed by the processor 601 to implement the random code generation method provided by the above-mentioned various method embodiments. Of course, the computer device 600 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The computer device 600 may also include other components for implementing device functions, which will not be described in detail here.

[0123] In an exemplary embodiment, a computer-readable storage medium is further provided, such as a memory including program code. The program code can be executed by a processor in a computer device to perform the random code generation method in the above embodiment. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0124] In an exemplary embodiment, a computer program product or computer program is also provided, which includes computer program code, which is stored in a computer-readable storage medium. A processor of a computer device reads the computer program code from the computer-readable storage medium, and the processor executes the computer program code, so that the computer device performs the above-mentioned random code generation method.

[0125] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.

[0126] The above description is merely an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A random code generation method, characterized in that: The method comprises: Generate a new random code based on the candidate characters; Perform deduplication verification on newly generated random codes based on the first data pool; wherein the first data pool is the union of the second data pool and the third data pool; the second data pool is used to store available random codes, and any two available random codes are unique; and the third data pool is used to store used random codes taken from the second data pool; In response to the newly generated random code passing the deduplication check, adding the newly generated random code to the first data pool and the second data pool respectively; Receive a random code acquisition request; In response to the number of random code acquisition requests being no greater than the number of random codes currently stored in the second data pool, randomly selecting a random code from the second data pool and issuing the selected random code; In response to the number of random code acquisition requests being greater than the number of random codes currently stored in the second data pool, the random codes currently stored in the second data pool are issued; and, based on the candidate characters, a first number of random codes are newly generated; in response to the first number of random codes passing the deduplication check, the first number of random codes are issued; wherein the first number is the difference between the number of random code acquisition requests and the number of random codes currently stored in the second data pool.

2. The method according to claim 1, characterized in that The second data pool is used to store a second number of available random codes; the method further includes: Periodically deleting part of the random codes stored in the third data pool, and deleting the part of the random codes stored in the first data pool together; The random codes that have not been deleted in the third data pool are a third number of random codes that have been recently taken out from the second data pool and used; and the second number is greater than the third number.

3. The method according to claim 1, characterized in that In response to the newly generated random code passing the deduplication check, adding the newly generated random code to the first data pool and the second data pool respectively includes: In response to the newly generated random code not existing in the first data pool, it is determined that the newly generated random code passes the deduplication check, and the newly generated random code is added to the first data pool and the second data pool respectively.

4. The method according to claim 1, wherein The step of generating a new random code based on the candidate characters includes: Determining a composition form of the random code, and constructing a character array according to the composition form of the random code; Deleting specific characters from the character array to obtain the candidate characters; wherein the specific characters include at least one set of easily confused character pairs; A random character string of specified digits is newly generated based on the candidate characters to obtain the random code.

5. A random code generating device, characterized in that: The device comprises: A generating module is configured to generate a new random code based on the candidate characters; A verification module is configured to perform deduplication verification on newly generated random codes based on a first data pool; wherein the first data pool is the union of a second data pool and a third data pool; the second data pool is used to store available random codes, and any two available random codes are unique; and the third data pool is used to store used random codes taken from the second data pool; a storage module configured to, in response to the newly generated random code passing the deduplication check, add the newly generated random code to the first data pool and the second data pool respectively; a processing module configured to receive a random code acquisition request; in response to the number of random code acquisition requests being no greater than the number of random codes currently stored in the second data pool, randomly select a random code from the second data pool, and issue the selected random code; The processing module is further configured to, in response to the number of random code acquisition requests being greater than the number of random codes currently stored in the second data pool, issue the random codes currently stored in the second data pool; and, based on the candidate characters, newly generate a first number of random codes; and, in response to the first number of random codes passing the deduplication check, issue the first number of random codes; wherein the first number is the difference between the number of random code acquisition requests and the number of random codes currently stored in the second data pool.

6. The device according to claim 5, characterized in that The second data pool is used to store a second number of available random codes; the device further includes: a deleting module configured to periodically delete part of the random codes stored in the third data pool and also delete the part of the random codes stored in the first data pool; The random codes that have not been deleted in the third data pool are a third number of random codes that have been recently taken out from the second data pool and used; and the second number is greater than the third number.

7. A computer device, characterized in that: The device includes a processor and a memory, wherein at least one program code is stored in the memory, and the at least one program code is loaded and executed by the processor to implement the random code generation method according to any one of claims 1 to 4.

8. A computer-readable storage medium, characterized in that The storage medium stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the random code generation method according to any one of claims 1 to 4.