CN111723360A - Voucher code processing method and device and storage medium - Google Patents

Voucher code processing method and device and storage medium Download PDF

Info

Publication number
CN111723360A
CN111723360A CN201910205237.6A CN201910205237A CN111723360A CN 111723360 A CN111723360 A CN 111723360A CN 201910205237 A CN201910205237 A CN 201910205237A CN 111723360 A CN111723360 A CN 111723360A
Authority
CN
China
Prior art keywords
code
credential
check code
check
random number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910205237.6A
Other languages
Chinese (zh)
Other versions
CN111723360B (en
Inventor
康运杰
杨逵
黄锦召
鲍阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910205237.6A priority Critical patent/CN111723360B/en
Publication of CN111723360A publication Critical patent/CN111723360A/en
Application granted granted Critical
Publication of CN111723360B publication Critical patent/CN111723360B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/45Structures or tools for the administration of authentication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/71Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information
    • G06F21/77Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information in smart cards
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/58Random or pseudo-random number generators
    • G06F7/588Random number generators, i.e. based on natural stochastic processes

Abstract

The invention provides a voucher code processing method, a voucher code processing device and a storage medium, wherein the method comprises the following steps: acquiring a target digit and a batch number of a certificate code to be generated; generating at least one random number according to the target digit; and adding the batch number into the random number to obtain a certificate code. The voucher code processing method, the voucher code processing device and the storage medium can generate voucher codes with different digits in a random number mode according to different digits and batch numbers, and improve the generation efficiency of the voucher codes while ensuring the safety of the voucher codes.

Description

Voucher code processing method and device and storage medium
Technical Field
The present invention relates to the field of electronic technologies, and in particular, to a credential code processing method, apparatus, and storage medium.
Background
At present, card coupon presentation in the internet era is increasingly the first choice for the public to give gifts at festivals, and after being taken by a presenter, the gift coupon is automatically sent to a shop to exchange for getting objects, so that the logistics cost of gift presentation is saved, and the gift quality can be guaranteed. In order to give the ticket the ability to be redeemed, the voucher code becomes an integral part of the ticket.
In the prior art, the mode of generating the credential code generally obtains a one-bit random number, then takes out corresponding characters from a basic character string by using the random number as an index, and splices the characters to obtain a character string, and when the character string reaches the bit number required by the credential code, the cycle is ended to obtain a final character string, namely the credential code.
By adopting the prior art, when the voucher code is generated, the repeated generation efficiency is low due to the fact that the character strings need to be spliced continuously, and the security of the voucher code is low and the voucher code is easy to crack due to the fact that the digit of the voucher code is fixed.
Disclosure of Invention
The invention provides a voucher code processing method, a voucher code processing device and a storage medium, which can generate voucher codes with different digits in a random number mode according to different digits and batch numbers, and improve the generation efficiency of the voucher codes while ensuring the safety of the voucher codes.
The first aspect of the present invention provides a credential code processing method, including:
acquiring a target digit and a batch number of a certificate code to be generated;
generating at least one random number according to the target digit, wherein the sum of the digit of the at least one random number and the digit of the batch number is the same as the target digit;
and adding the batch number into the at least one random number to obtain at least one certificate code.
In an embodiment of the first aspect of the present invention, the lot number includes at least two bits; adding the batch number into the random number to obtain a certificate code, comprising:
and splitting the batch number into two parts, and adding the batch numbers of the two parts into the beginning and the end of the random number respectively to obtain the voucher code.
In an embodiment of the first aspect of the present invention, after generating at least one random number according to the target number of bits, the method further includes:
and deleting the random numbers with continuous N-bit same numbers in the at least one random number, wherein N is a positive integer less than or equal to the number of bits of the random numbers.
In an embodiment of the first aspect of the present invention, after the adding the batch number to the random number to obtain the credential code, the method further includes:
calculating a check code of the voucher code through a check code algorithm; wherein the check code is used to verify the authenticity of the credential code;
adding the check code to the voucher code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding the first character string into the certificate code to obtain a character string group;
converting the character string group into an AscII array;
carrying out weighted summation on the AscII array to obtain a check code index;
and determining the check code corresponding to the check code index according to a mapping relation, wherein the mapping relation comprises the corresponding relation between at least one check code index and at least one check code.
In an embodiment of the first aspect of the present invention, the first character string includes: letters, numbers, or a combination string of letters and numbers.
In a first embodiment of the first aspect of the invention, a validation request for a redemption code to be validated is obtained, the validation request including the redemption code to be validated;
determining a first certificate code and a first check code in the redemption code to be verified;
calculating a second check code of the credential code by the check code algorithm;
and if the first check code is different from the second check code, determining that the first certificate code of the exchange code to be verified is wrong.
A second aspect of the present invention provides a credential code processing apparatus, including:
the acquisition module is used for acquiring the target digit and batch number of the certificate code to be generated;
the processing module is used for generating at least one random number according to the target digit, and the sum of the digits of the at least one random number and the batch number is the same as the target digit;
the processing module is further configured to add the batch number to the at least one random number to obtain at least one credential code.
In an embodiment of the second aspect of the present invention, the lot number includes at least two bits; the processing module is specifically configured to split the batch number into two parts, and add the batch numbers of the two parts to the beginning and the end of the random number respectively to obtain the credential code.
In an embodiment of the second aspect of the present invention, the processing module is further configured to delete a random number having a same number with N consecutive bits in the at least one random number.
In an embodiment of the second aspect of the present invention, the processing module is further configured to calculate a check code of the credential code through a check code algorithm; wherein the check code is used to verify the authenticity of the credential code;
adding the check code to the voucher code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding the first character string into the certificate code to obtain a character string group;
converting the character string group into an AscII array;
carrying out weighted summation on the AscII array to obtain a check code index;
and determining the check code corresponding to the check code index according to a mapping relation, wherein the mapping relation comprises the corresponding relation between at least one check code index and at least one check code.
In an embodiment of the second aspect of the present invention, the first character string includes: letters, numbers, or a combination string of letters and numbers.
In an embodiment of the second aspect of the present invention, the method further includes: the verification module is used for acquiring a verification request of a redemption code to be verified, and the verification request comprises the redemption code to be verified;
determining a first certificate code and a first check code in the redemption code to be verified;
calculating a second check code of the credential code by the check code algorithm;
and if the first check code is different from the second check code, determining that the first certificate code of the exchange code to be verified is wrong.
A third aspect of the present invention provides a credential code processing apparatus, including: a processor, a memory, and a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor, the computer program comprising instructions for performing the credential code processing method of any of the preceding embodiments.
A third aspect of the present invention provides a storage medium storing a computer program that causes a server to execute the credential code processing method according to any one of the preceding embodiments.
In summary, the present invention provides a credential code processing method, apparatus and storage medium, wherein the method includes: acquiring a target digit and a batch number of a certificate code to be generated; generating at least one random number according to the target digit; and adding at least one batch number into at least one random number to obtain a certificate code. The voucher code processing method, the voucher code processing device and the storage medium can generate voucher codes with different digits in a random number mode according to different digits and batch numbers, and improve the generation efficiency of the voucher codes while ensuring the safety of the voucher codes.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention;
FIG. 6 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention;
FIG. 7 is a block diagram of a credential code processing device according to an embodiment of the present invention;
FIG. 8 is a block diagram of a credential code processing device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
FIG. 1 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention. As shown in fig. 1, the credential code processing method provided in this embodiment includes:
s101: and acquiring the target digit and the batch number of the certificate code to be generated.
Specifically, the executing body of the credential code processing method provided in this embodiment may be an electronic device with a related data processing function, for example: computers or servers, etc.; or, the device may also be a chip in an electronic device, such as a CPU or GPU.
The credential code processing method provided in this embodiment needs to determine the target number of bits and the batch number of the credential code to be generated through S101 before generating the credential code. The target number of digits of the credential code refers to the number of digits that the credential code provided by the credential code administrator can include in advance, for example, when the target number of digits of the credential code is 10, the credential code to be generated should include 10 digits such as "1111111111". The batch number refers to the batch information of the certificate code which needs to be generated currently, and the certificate code is stored in the database for later use after the certificate codes of one batch are generated once in the order of batch. When the number of the credential codes in the database is smaller than the preset threshold, a batch of credential codes is generated again, so that the specific batch to which the credential codes belong needs to be determined. In one possible implementation, the credential code may include at least two digits, for example, the first batch of verification codes has a batch number of 00, the second batch of verification codes has a batch number of 01, and so on.
S102: and generating at least one random number according to the target digit, wherein the sum of the digit of the at least one random number and the digit of the batch number is the same as the target digit.
Specifically, in S102, at least one random number is generated according to the number of bits of the voucher code determined in S101. In order to carry the batch number in the certificate code, the number of bits of the random number generated in S102 should be equal to the difference between the number of bits of the certificate code and the number of bits of the batch number. For example: if the target digit determined in S101 is 10, the lot number is 01, that is, the digit of the lot number is 2, the digit of at least one random number that needs to be generated in S102 should be 8, and the credential code that is finally generated in this embodiment can be obtained by combining the at least one random number with the lot number.
In one possible implementation manner, at least one random number is generated in S102, and after the number of bits of the random number is determined, the natural numbers corresponding to the number of bits may be all used as the generated at least one random number. For example: if it is determined that the number of bits of the at least one random number to be generated should be 8 bits, it can be determined that the at least one 8-bit natural number is 10000000 and 99999999 is the at least one random number.
Optionally, in the above embodiment, a one-bit check code for verifying the credential code may be further included in the credential code, and then, when generating the at least one random number, it is necessary to further subtract the number of bits of the check code, and then use at least one 7-bit natural number 1000000 and 9999999 as the at least one random number.
Further, in this embodiment, after the at least one random number is determined in S102, the random number having consecutive N-bit same number in the at least one random number is deleted, where N is a positive integer less than or equal to the number of bits of the random number.
Specifically, in this embodiment, since a certain random number is added to the credential code, and if there is a random number with consecutive identical digits, such as "1100000", the random number has a great risk of being enumerated, and the user of the credential code only needs to know that the previous two digits are followed by consecutive "0" to steal the credential code. Therefore, in the present embodiment, although at least one random number is determined by means of random generation, the random number having too many consecutive identical numbers in the random number cannot be used as the random number for subsequently generating the credential code.
For example: in one possible implementation, again taking the 7-bit natural numbers 1000000 and 9999999 as examples, N may be designated 3. In this embodiment, after all the natural numbers including consecutive 3 identical numbers in the 7-bit natural number, for example, the natural numbers such as "1000000" or "1234555" are deleted, at least one random number with duplicates removed is obtained: 1001001, 1001002, 1001003 … ….
S103: and adding at least one batch number into the random number to obtain at least one certificate code.
Specifically, in S103, the batch number determined in S101 is added to the at least one random number generated in S102 to obtain at least one credential code composed of the batch number and the at least one random number together.
Optionally, in a possible implementation manner of S103, the batch number is split into two parts, and the two parts of batch numbers are added to the beginning and the end of the random number respectively to obtain the credential code. For example: when the lot number is a two-digit "10", the lot number can be split into "1" and "0". And "1" and "0" are added to the random number "1001001" to obtain "110010010". Finally, since the verification code of the credential code is also included in this example, the verification code can be calculated according to the 9-bit credential code "110010010" and then added to the verification code, so as to finally obtain the 10-bit credential code. In the same manner as in this example, after the at least one random number determined in S102 is added to the batch number, at least one credential code can be finally obtained, the generation operation of the credential code is completed, and the credential code can be subsequently stored in the database for use.
In summary, in the voucher code processing method provided in this embodiment, voucher codes with different digits can be generated in a random number manner according to different digits and batch numbers. Compared with the certificate code with fixed digits in the prior art, the certificate code with more flexible digits can be generated, and the generation efficiency of the certificate code is improved while the safety of the certificate code is ensured. Meanwhile, the voucher codes are generated in a random number mode, so that a large number of voucher codes can be generated in a short time, and different from the mode of independently determining the numerical value of each bit in each voucher code in the prior art, the generation efficiency can be improved in the process of generating the voucher codes in batches.
Further, after at least one credential code can be generated through the process shown in fig. 1, a check code for verifying the authenticity of the credential code needs to be added to the credential code. The string of characters consisting of the voucher code and its check code can be called the redemption code. The redemption code is used to verify the authenticity of the credential code therein with a verification code that can be passed therethrough in subsequent use of the credential code.
Specifically, after S103, a check code of the credential code may be further calculated by a check code algorithm for each generated credential code; and adding the calculated check code to the voucher code to obtain a redemption code. And (4) performing the calculation on at least one certificate code determined in the step (S103) to finally obtain at least one exchange code, and subsequently storing the exchange code into a database for use.
FIG. 2 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention. Fig. 2 shows a possible implementation method of the check code algorithm in the above embodiment, where the check code algorithm includes:
s201: and adding the first character string into the certificate code to obtain a character string group.
Specifically, to calculate the authentication code of the credential code, a first character string is first added to the credential code. The first character string may be a unique character string provided by a credential code manager, and only a person or device related to check code calculation can acquire the first character string and perform subsequent calculation according to the fixed first character string.
Preferably, the first character string described in the embodiments of the present application includes: letters, numbers, or a combination string of letters and numbers. For example: in one possible implementation manner of the embodiment, the first character string is set as the combined character string of the letters and the numbers of 6e1fd6ebb48a, and then the first character string needs to be added to the credential code "110010010" in S201. Alternatively, the first character string may be added to the credential code, and the credential code and the first character string may be concatenated to obtain a character string set "1100100106 e1fd6ebb48 a".
S202: converting the character string group into an AscII array;
subsequently, since the character string set determined in S201 has both numbers and letters, it is necessary to convert the character string set into the form of AscII code to form an AscII array in S202. For example: the above-described character string set determined in S201 may be converted into an AscII array of "4949484849484849485410149102100541019898525697" in S202 according to the conversion rule of AscII codes.
S203: weighting and summing the AscII array to obtain a check code index;
subsequently, in order to further ensure the security performance of the AscII array, in this step, the AscII array also needs to be subjected to weighted summation calculation, the specific weighted value and the weighting mode can also be set by the administrator of the credential code, and only the person or device related to the check code calculation can acquire the specific rule of the weighted summation.
TABLE 1
Weighted number a 4 9 4 9 4 8 4 8 4 …… 5 6 9 7
Weighting factor b 7 9 6 5 2 5 8 9 8 …… 9 4 9 4
Weight c 5 8 4 2 1 6 3 7 9 …… 5 8 4 2
Weighting a c 20 72 16 18 4 48 12 56 36 …… 25 48 36 14
For example, as shown in table 1, the AscII array determined in the above step is used as a weighting number a, the AscII arrays are arranged in reverse order to obtain a weighting factor b, and then the weighting factor b is obtained by formula 2bThe weight c is calculated as% 11 ═ c. That is, the weight c is obtained by performing a remainder operation on the power b of 2 and the power 11. For example: the weighting factor a is 128 to the power of 7 of the weighting factor 2, and the weight c of the weighting factor a is obtained by performing a remainder operation on 128 and 11 and obtaining 5.
And then, multiplying each weighted number a by the corresponding weight c, and taking the modulo budget of 10 by the value obtained by summing the products of all weighted numbers and the weights c to obtain the check code index of 6.
S204: and determining the check code corresponding to the check code index according to the mapping relation, wherein the mapping relation comprises the corresponding relation between at least one check code index and at least one check code.
For example: table 2 shows a mapping relationship between check code indexes and check codes, where each check code index has a corresponding check code. The check code 6 calculated in S203 can finally be summarized from the mapping relationship in table 6 to be determined as 3.
TABLE 2
Check code index 0 1 2 3 4 5 6 7 8 9
Check code 6 5 8 2 4 0 3 1 9 7
Subsequently, after the check code is calculated by the check code algorithm as shown in fig. 2, the check code may be inserted into the credential code. For example, in one possible implementation, a verification code may be inserted in an intermediate location, e.g., the 4 th digit, of the credential code "110010010" to yield the complete redemption code "1103010010".
In summary, in the voucher code processing method provided in this embodiment, after the original voucher code is generated, the check code for verifying the voucher code is further obtained by calculation according to the voucher code, and the exchange code that can be used finally is obtained after the check code is inserted into the voucher code. Especially, in the process of generating the check code, letters or the combination of numbers and letters can be used in the first character string, so that the numbers can be used as the certificate code, and the accuracy of the check code calculated by the certificate code is further improved compared with the calculation mode of the pure digital certificate code in the prior art.
Further, on the basis of calculating the check code by the credential code in the foregoing embodiment, the present implementation also provides a credential code processing method for verifying the check code of the credential code in the exchange, specifically, as shown in fig. 3, the method includes:
s301: obtaining a verification request of the redemption code to be verified, wherein the verification request comprises the redemption code to be verified;
s302: determining a first certificate code and a first check code in a redemption code to be verified;
s303: calculating a second check code of the first certificate code through a check code algorithm;
s304: judging whether the first check code is the same as the second check code;
s305: if the first check code is different from the second check code, determining that the first certificate code of the exchange code to be verified is wrong;
s306: and if the first check code is the same as the second check code, continuously verifying the first certificate code of the redemption code to be verified.
Specifically, in this embodiment, in order to improve the exchange efficiency of the voucher code in the exchange code, after receiving the verification request requesting verification of the exchange code in S301, first, in S302, the first voucher code and the first check code in the exchange code are extracted. And calculates a second check code through a check code algorithm for the extracted first voucher code in S303 by the embodiment shown in fig. 2. If the first voucher code in the redemption code is correct, the second verification code, calculated by the same verification code algorithm used in generating the redemption code, should be the same as the first verification code in the redemption code. The first check code and the second check code need to be compared in S304, and if they are different, it can be determined in S305 that the first credential code in the redemption code is incorrect and the credential code is no longer verified; if the two are the same, the first credential code is further verified in S306.
Therefore, in the method for verifying the exchange code provided by the embodiment, whether the verification code of the voucher code is correct or not can be calculated preferentially during exchange, and if the verification code is wrong, the voucher code can be considered to be wrong, and the exchange failure is returned. And when the check code is correct, the database retrieval is carried out. Compared with the prior art that each voucher code needs to enter the retrieval database during verification, the method reduces the calculation amount of retrieval in the database, and improves the speed and performance of the verification process of the exchange code.
In summary, the credential code processing method provided in this embodiment can check the check code before verifying the credential code based on the check code algorithm used in the generation of the check code, and if none of the check codes passes the check, the credential code can be determined to be incorrect without continuing to check the credential code, so that the calculation pressure on the server caused by the verification of the credential code is increased by a faster, more effective and simpler check code verification method.
Further, based on the above embodiment, the present invention further provides a flowchart for applying the credential code processing method in the present application to the specific operation of the server in the actual credential code generation server. Next, an overall flow example of a credential code processing method applied in the present application will be described with reference to fig. 4 and 5.
First, since the number of bits of the credential code can be adjusted in the embodiment of the present application, the number of bits of the generated credential code can be controlled by configuration. Therefore, in order to implement the credential code processing method in this embodiment, an enumeration configuration of the number of credential codes to be generated needs to be specified first.
TABLE 3
Field(s) Description of the invention
code Enumerating values stored in a database
name Voucher code digit and voucher code type (letter, number, letter + number) combination
initBatchNum Generating an initial value of a credential code batch number
initialCodeKey Key of initial voucher code in cache
availableCodeKey Keys in cache for available credential codes
desc Enumerated value description
Table 3 shows a specific implementation example of an enumeration configuration, where a field code in the code is used to indicate the manner of the determined credential code, e.g., when code is 1, the credential code is 10 bits, and when code is 2, the credential code is 12 bits. The field name is used to determine whether the credential code to be determined is alphabetical or numeric or a combination of alphabetical and numeric. The field initBatchNum is used to indicate the initial value of the batch number of the generated credential code. The field initialCodeKey is used to represent the cache identification (key) of the initial credential code in the cache. The field availableCodeKey is used to indicate the cache identification (key) of the available credential code in the cache. The field desc serves as remark information and may add an associated description of the credential code.
As shown in fig. 4, after the initial credential code task is generated by the trigger of the timer, the enumeration configuration of the number of generated credential codes is read first, the number of initial credential codes in the cache is read through the field initialcodedkey in the enumeration configuration, and if the number is greater than 0, it indicates that the initial credential codes in the cache are not put in storage and the task is directly ended.
If the initial voucher code number is equal to 0, reading an attribute availablecordeKey in enumeration configuration, reading the available voucher code number in the cache through the attribute, counting the unused voucher code number in the database through the enumeration attribute code, adding the available code number in the cache and the unused voucher code number in the database, comparing the summation result with a threshold value codeInAvlQty, and if the summation result is greater than the threshold value codeInAvlQty, indicating that the available voucher codes are sufficient and do not need to be generated, directly ending the task.
And when the summation result is less than the threshold value codeminavalqty, generating an initial credential code. Acquiring an enumeration attribute code, inquiring the maximum batch number of the enumeration corresponding certificate code in a database through the attribute, if the batch number exists, adding 1 to the batch number to obtain the batch number of the certificate generated at this time, and if the maximum batch number does not exist in the database, taking the attribute initBatchNum in the enumeration configuration as the batch number of the certificate generated at this time.
After the batch number is obtained, an enumeration attribute name is obtained, the digit of the voucher code to be generated is obtained through interception, and the method comprises the following steps: and 10^ (certificate code bit number-batch number bit number-check code bit number-first bit) and calculating to obtain an initial certificate code initial value. And multiplying the initial value by 10 and then subtracting 1 to obtain the end value of the initial certificate code.
Circularly processing the numbers between the starting value and the ending value, and performing the following operations: in order to reduce the cracking probability of the voucher code, the numbers of the three-serial numbers are discarded in a loop, for example, 111,222 … …, then the first bits of the batch number are spliced in front of the numbers, the rest bits are spliced behind the numbers, finally the initial voucher code is formed, and the initial voucher code is sequentially put into a set. After circulation is finished, the sequence of the initial voucher codes in the collection is scrambled by using a shuffling algorithm, the collection after the sequence scrambling is stored in a cache in batches, redis is used as a cache system and a list data structure of the cache system, access and quantity statistics of the voucher codes are facilitated, and after all storage is finished, the task of generating the initial voucher codes is executed and finished.
The following step of generating the initial credential code is also described by taking a 10-bit digital credential code as an example, and includes: 1. and (5) initializing configuration. Obtaining credential code length enumeration: TEN _ DIGITAL (1, "10_1",10, "init _ TEN _ DIGITAL", "avl _ TEN _ DIGITAL", "10-digit pure number"); obtaining a threshold value codeminavalqty: 1000, parts by weight; the number of the check code of the obtained certificate code is 1. 2. Caching keys through the initial credential code: and (3) acquiring the initial certificate code number initQty in the cache by init _ ten _ digital, and if the initQty is greater than 0, directly ending the task. 3. Assuming the initQty is equal to 0, then the key is cached by the available credential code: avl _ ten _ digital acquires the number of available voucher codes in redis, allQty; then, conditioned on the enumeration code and the credential code usage status (unused), the value is determined by sql: the method comprises the steps that (1) the SELECT COUNT (1) FROM xxx where length _ type is 1and is _ used is 1, the number of available voucher codes in a statistical database is dbAvlQty, the avalQty and dbAvlQty are added, the obtained sum is compared with minAvlQty, and if the sum is larger than minAvlQty, the task is ended. If it is less than minAvlQty, the task continues to execute downwards. 4. Conditioned on enumerating codes, the code is determined by sql: SELECT max (batch _ number) from xxx where length _ type ═ 1 gets the maximum value of batch number in the database maxBatchNum, where assuming maxBatchNum is empty, then use the enumeration initBatchNum: 10 is used as the batch number generated this time. 5. Obtaining the length of a certificate code to be generated configured in enumeration: 10, calculating a starting value of the certificate code: 10^ (10-2 (batch number bit) -1 (check code bit) -1 (first bit)) ═ 1000000, end value: the initial value 10-1 is 9999999. 6. The numbers of 1000000 and 9999999 are circulated, and after three serial numbers are discarded, the batch number 10 is subjected to 1001001, 1001002 and 1001003 … …, the head is spliced at the head of the number, and 0 is spliced at the end to obtain: 110010010, 110010020, 110010030 … … generate 850w initial credential codes at one time, forming a set list. 7. And adding the list obtained by the step into a redis cache in batches by taking the init _ ten _ digital as a key.
It should be noted that, as the credential code processing method provided in the embodiment in fig. 4, the generated initial credential code is the same as the credential code generated in fig. 1. The difference is that in practical applications, the credential code generated by the credential code processing method of this embodiment needs subsequent processing, such as uploading to a server and adding a check code, after being generated in the cache, so that the generated credential code is not the final credential code, and may be referred to as an initial credential code in some practical applications.
Further, after the initial voucher code is generated by the embodiment shown in fig. 4, in order to obtain the final voucher code, a check code of the voucher code needs to be calculated, and the check code and the voucher code are jointly composed into a usable redemption code. Therefore, an embodiment of the present application further provides a method for generating a check code of a credential code on the basis of the foregoing, so as to add the initial credential code generated in the memory in fig. 4 into the check code and send the initial credential code to the database for encrypted storage.
In order to implement the calculation configuration of the check code, the table structure of the storage code table of the credential code may also be configured.
TABLE 4
Name of field Type (B) Length of Description of the invention
length_type tinyint 3 Credential code type enumeration value
batch_number int 10 Batch number
code varchar 128 Voucher code encryption value
is_used tinyint 1 Whether or not to use
For example: table 4 shows a stored code table of one possible credential code, where the field length _ type is the same as the field code in table 3. Field batch _ number: the method comprises the steps that the batch number is spliced at the head and the tail of an initial certificate code, so that the head of the initial certificate code is the head of the batch number, the number of bits obtained by subtracting the head of the initial batch number from the number of the initial certificate code is the initial position index of the last bits of the batch number in the initial certificate code, the last bits of the batch number are intercepted from the initial certificate code after the index is obtained, and the batch number is obtained after the head and the last bits of the batch number are spliced. The field code is the generated check code. Field is _ used: for identifying whether the credential code is used.
Fig. 5 is a flowchart illustrating a credential code processing method according to an embodiment of the present invention. In fig. 5, the task of storing the voucher in the database may also be triggered by a timing task, in which the voucher code and the check code are combined into a redemption code and uploaded to the database after calculating the check code according to the voucher code. And reading the initial credential code number in the redis through the field initialcodedKey, wherein if the number is equal to 0, the task is ended. If the number is larger than 0, the characteristic that the tail element of the list key can be removed and returned by utilizing the redis RPOP command is utilized, the RPOP command is circularly called to take out the initial credential code, and each field of the credential storage code table is assigned with a value after the initial credential code is taken out.
The following steps of obtaining a final redemption code from an initial voucher code are also described by way of example of a 10 digit voucher code, comprising: 1. the initial credential code 110010010 is fetched using the redis rpop command. 2. Set voucher code table field value length _ type: the ten digit type code is 1. 2. batch _ number: the first bit is the first bit of the credential code 110010010, i.e. 1, and the remaining bits are obtained by: firstly, using a formula: the number (9) of the initial voucher code is the number (1) of the initial batch number divided by the first bit, so that the index position 8 of the residual number of the batch number in the initial voucher code is obtained, and the last bit 0 of the batch number is obtained by intercepting the bit after the index position 8. And splicing the batch number 1and the tail bit 0 to obtain a batch number 10. 3. code: firstly, in order to improve the security of the key, the key is preferentially set as a character string mixed by letters and numbers, and the key is assumed as follows: 6e1fd6ebb48a, the initial credential code 110010010 is concatenated with the check code computation key and then converted to AscII: 4949484849484849485410149102100541019898525697. the complete redemption code is then 1103010010 by calculating the verification code as in the example shown in figure 2 in conjunction with tables 1and 2. 4. And adding the complete exchange codes into the set, storing the complete exchange codes into the database together after a certain number of exchange codes are reached, and storing the exchange codes into the database from a cache for subsequent selection and use.
In summary, through the embodiments of fig. 4 and fig. 5, the redemption code including the voucher code and the check code can be finally obtained and stored in the database of the server, and it can be understood that a plurality of batches of redemption codes are stored in the server. In actual use, in order to improve the use efficiency of the exchange code, the exchange code to be used each time is stored in the cache from the database, so that the exchange code can be determined more quickly from the cache.
For example: FIG. 6 is a flowchart illustrating a credential processing method according to an embodiment of the present invention. The process of extracting the redemption code from the database into the cache is shown in figure 6. When the certificate code is stored in the database, because the data volume of the certificate code table is large, a certain number of certificate codes can be pushed into the memory redis in advance for improving the performance of issuing the certificate code, and the certificate codes are directly acquired from the redis when being issued. In order to ensure high availability of the system, a timing task is used for monitoring the number of available credential codes in the redis, and when the number of available credential codes in the redis is insufficient, a batch of unused credential codes are inquired from a credential code table and pushed into the redis. The method comprises the following specific steps: firstly, reading a digit type enumeration attribute availableModeKey, reading the number of available certificate codes in the redis according to the cache key, and if the number of the available codes is greater than or equal to a threshold minNumInCache, directly ending the task; otherwise, the task is continuously executed downwards, a batch of unused certificate codes are inquired from the certificate code table and then pushed into the redis, and then the state of the batch certificate codes in the table is updated to be used. And circularly executing the operation until the number of the credential codes in the redis is greater than a threshold minNumInCache.
FIG. 7 is a block diagram of a credential code processing device according to an embodiment of the present invention. As shown in fig. 7, the credential code processing apparatus provided in this embodiment includes: an acquisition module 701 and a processing module 702. The obtaining module 701 is configured to obtain a target digit and a batch number of a credential code to be generated; the processing module 702 is configured to generate at least one random number according to the target digit, where a sum of the digit of the at least one random number and the digit of the batch number is the same as the target digit; the processing module 702 is further configured to add the batch number to at least one random number to obtain at least one credential code.
The credential code processing apparatus provided in this embodiment can be used to execute the credential code processing method shown in fig. 1, and the implementation method and principle thereof are the same, and are not described again.
Optionally, the processing module 702 is specifically configured to split the batch number into two parts, and add the two parts of the batch number to the beginning and the end of the random number respectively to obtain the credential code.
Optionally, the processing module 702 is further configured to delete at least one random number having a number with N consecutive same bits, where N is a positive integer less than or equal to the number of bits of the random number.
Optionally, the processing module 702 is further configured to calculate a check code of the credential code through a check code algorithm; the verification code is used for verifying the authenticity of the certificate code;
adding the check code into the voucher code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding the first character string into the certificate code to obtain a character string group;
converting the character string group into an AscII array;
weighting and summing the AscII array to obtain a check code index;
and determining the check code corresponding to the check code index according to the mapping relation, wherein the mapping relation comprises the corresponding relation between at least one check code index and at least one check code.
Optionally, the first string comprises: letters, numbers, or a combination string of letters and numbers.
FIG. 8 is a block diagram of a credential code processing device according to an embodiment of the present invention. The apparatus shown in fig. 8 is based on the embodiment shown in fig. 7, and further comprises: a verification module 801. A validation request for obtaining a redemption code to be validated, the validation request including the redemption code to be validated; determining a first certificate code and a first check code in a redemption code to be verified; calculating a second check code of the credential code through a check code algorithm; and if the first check code is different from the second check code, determining that the certificate code of the exchange code to be verified is wrong.
It should be noted that, in the embodiment of the present application, the division of the module is schematic, and is only one logic function division, and there may be another division manner in actual implementation. Each functional module in the embodiments of the present application may be integrated into one processing module, or each module may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The integrated module, if implemented in the form of a software functional module and sold or used as a separate product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method of the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The procedures or functions according to the embodiments of the present application are all or partially generated when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
The present invention also provides a credential code processing apparatus, including: a processor, a memory, and a computer program; wherein a computer program is stored in the memory and configured to be executed by the processor, the computer program comprising instructions for performing the credential code processing method as in any one of the preceding embodiments.
The present invention also provides a storage medium storing a computer program that causes a server to execute the credential code processing method according to any one of the preceding embodiments.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A credential code processing method, comprising:
acquiring a target digit and a batch number of a certificate code to be generated;
generating at least one random number according to the target digit, wherein the sum of the digit of the at least one random number and the digit of the batch number is the same as the target digit;
and adding the batch number into the at least one random number to obtain at least one certificate code.
2. The method of claim 1, wherein the batch number includes at least two bits; adding the batch number into the random number to obtain a certificate code, comprising:
and splitting the batch number into two parts, and adding the batch numbers of the two parts into the beginning and the end of the random number respectively to obtain the voucher code.
3. The method of claim 1, wherein after generating at least one random number according to the target number of bits, further comprising:
and deleting the random numbers with continuous N-bit same numbers in the at least one random number, wherein N is a positive integer less than or equal to the number of bits of the random numbers.
4. The method according to any one of claims 1-3, wherein after adding the batch number to the random number to obtain a credential code, further comprising:
calculating a check code of the voucher code through a check code algorithm; wherein the check code is used to verify the authenticity of the credential code;
adding the check code to the voucher code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding the first character string into the certificate code to obtain a character string group;
converting the character string group into an AscII array;
carrying out weighted summation on the AscII array to obtain a check code index;
and determining the check code corresponding to the check code index according to a mapping relation, wherein the mapping relation comprises the corresponding relation between at least one check code index and at least one check code.
5. The method of claim 4,
the first string includes: letters, numbers, or a combination string of letters and numbers.
6. The method of claim 4, further comprising:
obtaining a verification request of a redemption code to be verified, wherein the verification request comprises the redemption code to be verified;
determining a first certificate code and a first check code in the redemption code to be verified;
calculating a second check code of the credential code by the check code algorithm;
and if the first check code is different from the second check code, determining that the first certificate code of the exchange code to be verified is wrong.
7. A credential code processing apparatus, comprising:
the acquisition module is used for acquiring the target digit and batch number of the certificate code to be generated;
the processing module is used for generating at least one random number according to the target digit, and the sum of the digits of the at least one random number and the batch number is the same as the target digit;
the processing module is further configured to add the batch number to the at least one random number to obtain at least one credential code.
8. The apparatus of claim 7,
the processing module is also used for calculating the check code of the certificate code through a check code algorithm; wherein the check code is used to verify the authenticity of the credential code;
adding the check code to the voucher code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding the first character string into the certificate code to obtain a character string group;
converting the character string group into an AscII array;
carrying out weighted summation on the AscII array to obtain a check code index;
and determining the check code corresponding to the check code index according to a mapping relation, wherein the mapping relation comprises the corresponding relation between at least one check code index and at least one check code.
9. A credential code processing apparatus, comprising: a processor, a memory, and a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor, the computer program comprising instructions for performing the credential code processing method of any one of claims 1-7.
10. A storage medium storing a computer program that causes a server to execute the credential code processing method of any one of claims 1-7.
CN201910205237.6A 2019-03-18 2019-03-18 Credential code processing method, device and storage medium Active CN111723360B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910205237.6A CN111723360B (en) 2019-03-18 2019-03-18 Credential code processing method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910205237.6A CN111723360B (en) 2019-03-18 2019-03-18 Credential code processing method, device and storage medium

Publications (2)

Publication Number Publication Date
CN111723360A true CN111723360A (en) 2020-09-29
CN111723360B CN111723360B (en) 2023-11-03

Family

ID=72563161

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910205237.6A Active CN111723360B (en) 2019-03-18 2019-03-18 Credential code processing method, device and storage medium

Country Status (1)

Country Link
CN (1) CN111723360B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113240471A (en) * 2021-05-19 2021-08-10 完美世界(北京)软件科技发展有限公司 Prize exchanging code generation method and device, electronic device and storage medium
CN113318456A (en) * 2021-06-30 2021-08-31 完美世界(重庆)互动科技有限公司 Data voucher system, method, apparatus and medium
CN113762958A (en) * 2021-01-04 2021-12-07 北京沃东天骏信息技术有限公司 Method and device for generating electronic certificate

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014065754A1 (en) * 2012-10-24 2014-05-01 Visitor Information Pte Ltd Apparatus and methods for generating and/or validating redemption codes
CN103838753A (en) * 2012-11-23 2014-06-04 腾讯科技(北京)有限公司 Storage and verification method and device for exchange codes
CN105373927A (en) * 2014-08-26 2016-03-02 腾讯科技(深圳)有限公司 Coupon code generation method of electronic coupon, device and server
US20160132871A1 (en) * 2012-06-07 2016-05-12 Google Inc. Secure redemption code generation for gift cards and promotions
CN106097014A (en) * 2016-06-17 2016-11-09 武汉斗鱼网络科技有限公司 A kind of system and method being exchanged virtual present by redemption code
CN106355425A (en) * 2015-07-15 2017-01-25 阿里巴巴集团控股有限公司 Method for generating verification codes of electronic certificates and verification canceling method and device for electronic certificates
CN106972918A (en) * 2017-03-15 2017-07-21 中国工商银行股份有限公司 A kind of generation method, device and the verification method of electronic code data
CN108197938A (en) * 2017-12-28 2018-06-22 广州隆昇科技有限公司 A kind of electronics redemption card certificate method for secure transactions and system based on time sequence status

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160132871A1 (en) * 2012-06-07 2016-05-12 Google Inc. Secure redemption code generation for gift cards and promotions
WO2014065754A1 (en) * 2012-10-24 2014-05-01 Visitor Information Pte Ltd Apparatus and methods for generating and/or validating redemption codes
CN103838753A (en) * 2012-11-23 2014-06-04 腾讯科技(北京)有限公司 Storage and verification method and device for exchange codes
CN105373927A (en) * 2014-08-26 2016-03-02 腾讯科技(深圳)有限公司 Coupon code generation method of electronic coupon, device and server
CN106355425A (en) * 2015-07-15 2017-01-25 阿里巴巴集团控股有限公司 Method for generating verification codes of electronic certificates and verification canceling method and device for electronic certificates
CN106097014A (en) * 2016-06-17 2016-11-09 武汉斗鱼网络科技有限公司 A kind of system and method being exchanged virtual present by redemption code
CN106972918A (en) * 2017-03-15 2017-07-21 中国工商银行股份有限公司 A kind of generation method, device and the verification method of electronic code data
CN108197938A (en) * 2017-12-28 2018-06-22 广州隆昇科技有限公司 A kind of electronics redemption card certificate method for secure transactions and system based on time sequence status

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113762958A (en) * 2021-01-04 2021-12-07 北京沃东天骏信息技术有限公司 Method and device for generating electronic certificate
CN113240471A (en) * 2021-05-19 2021-08-10 完美世界(北京)软件科技发展有限公司 Prize exchanging code generation method and device, electronic device and storage medium
CN113318456A (en) * 2021-06-30 2021-08-31 完美世界(重庆)互动科技有限公司 Data voucher system, method, apparatus and medium
CN113318456B (en) * 2021-06-30 2024-04-02 完美世界(重庆)互动科技有限公司 Data credential system, method, apparatus, and medium

Also Published As

Publication number Publication date
CN111723360B (en) 2023-11-03

Similar Documents

Publication Publication Date Title
CN107800819A (en) A kind of generation method of file identification, device and server
CN111723360A (en) Voucher code processing method and device and storage medium
CN107491519B (en) Method and device for inquiring block chain account book
CN106610995B (en) Method, device and system for creating ciphertext index
US20200019685A1 (en) Computer system, verification method of confidential information, and computer
CN112487253A (en) User invitation code generation method, verification method, device, equipment and storage medium
CN111859424B (en) Data encryption method, system, terminal and storage medium of physical management platform
CN108335208B (en) Method and apparatus for processing information
CN109446827B (en) Data encryption and decryption method and system
CN115757535A (en) Data query method, data storage method and device and electronic equipment
CN113032742B (en) Data desensitization method and device, storage medium and electronic device
CN113472868A (en) Block chain biological fingerprint identification method and system
CN113762958A (en) Method and device for generating electronic certificate
CN112883301A (en) Method and device for generating short link based on 55 system and storage medium
CN115935429B (en) Data processing method, device, medium and electronic equipment
CN112118087A (en) Cross-chain contract compression encryption system and method
CN117667016A (en) Random number generation method, device, computer equipment and storage medium
KR102352488B1 (en) Blockchain-based data management server that enables the storage and management of data through interlocking with the two-dimensional code inserted in the business card and operating method thereof
CN111291336A (en) Game registration method and device in game platform
CN117076509B (en) Data duplicate checking method, device, equipment and storage medium
CN113837765B (en) Payment verification method, device, equipment and storage medium
EP3361667A1 (en) Method and device to produce a secure hash value
CN112015758B (en) Product code-fetching method, device, computer equipment and storage medium
KR102518790B1 (en) Payment service providing server for providing utility bill payment service using virtual currency, and operating method thereof
CN116880778B (en) User privacy protection method based on regenerative coding and distributed storage

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant