CN111723360B - Credential code processing method, device and storage medium - Google Patents

Credential code processing method, device and storage medium Download PDF

Info

Publication number
CN111723360B
CN111723360B CN201910205237.6A CN201910205237A CN111723360B CN 111723360 B CN111723360 B CN 111723360B CN 201910205237 A CN201910205237 A CN 201910205237A CN 111723360 B CN111723360 B CN 111723360B
Authority
CN
China
Prior art keywords
code
credential
check code
batch
check
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.)
Active
Application number
CN201910205237.6A
Other languages
Chinese (zh)
Other versions
CN111723360A (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

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Physics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Computational Mathematics (AREA)
  • Storage Device Security (AREA)

Abstract

The invention provides a method, a device and a storage medium for processing a credential code, wherein the method comprises the following steps: acquiring the target bit number and the batch number of the credential code to be generated; generating at least one random number according to the target bit number; and adding the batch number into the random number to obtain the credential code. The credential code processing method, the credential code processing device and the storage medium can generate credential codes with different digits in a random number mode according to different digits and batch numbers, so that the security of the credential codes is ensured, and meanwhile, the generation efficiency of the credential codes is improved.

Description

Credential code processing method, device and storage medium
Technical Field
The present invention relates to the field of electronic technologies, and in particular, to a method and apparatus for processing a credential code, and a storage medium.
Background
At present, the coupon gift in the Internet age increasingly becomes the first choice of the public to send out gift every year, and the gift can be obtained by the gift giver after the gift giver takes the coupon and then exchanges the gift giver to the store, so that the logistics cost of gift giver is saved, and the gift quality can be ensured. To impart the ability to redeem the card, the credential code becomes an integral part of the card.
In the prior art, the method of generating the credential code generally takes a corresponding character from a basic character string by taking a random number as an index after obtaining the random number, splices the character to obtain the character string, and finishes the cycle after the character string reaches the bit number required by the credential code to obtain a final character string, namely the credential code.
When the prior art is adopted, the repeated generation efficiency is lower due to the fact that character strings are required to be continuously spliced when the credential codes are generated, and the security of the credential codes is low and the credential codes are easy to crack due to the fact that the digits of the credential codes are fixed.
Disclosure of Invention
The invention provides a credential code processing method, a credential code processing device and a storage medium, which can generate credential codes with different digits in a random number mode according to different digits and batch numbers, thereby improving the generation efficiency of the credential codes while ensuring the security of the credential codes.
The first aspect of the present invention provides a credential code processing method, including:
acquiring the target bit number and the batch number of the credential code to be generated;
generating at least one random number according to the target bit number, wherein the sum of the bit number of the at least one random number and the bit number of the batch number is the same as the target bit number;
and adding the batch number into the at least one random number to obtain at least one credential code.
In a first embodiment of the first aspect of the present invention, the lot number includes at least two bits; the adding the batch number to the random number to obtain a credential code comprises:
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 credential code.
In a first embodiment of the first aspect of the present invention, after the generating at least one random number according to the target bit number, the method further includes:
deleting random numbers with the same number in N continuous digits in the at least one random number, wherein N is a positive integer less than or equal to the digits of the random numbers.
In an embodiment of the first aspect of the present invention, after adding the batch number to the random number to obtain a credential code, the method further includes:
calculating a check code of the credential code through a check code algorithm; wherein the check code is used for verifying the authenticity of the credential code;
adding the check code into the credential code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding the first character string into the credential 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 a first embodiment of the first aspect of the present invention, the first string includes: letters, numbers, or a combination of letters and numbers.
In a first embodiment of the first aspect of the present invention, a verification request for a redemption code to be verified is obtained, the verification request including the redemption code to be verified;
determining a first credential 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;
if the first check code is different from the second check code, determining that the first credential code of the to-be-verified redemption code is wrong.
A second aspect of the present invention provides a credential code processing device, including:
the acquisition module is used for acquiring the target bit number and the batch number of the credential code to be generated;
the processing module is used for generating at least one random number according to the target bit number, and the sum of the bit number of the at least one random number and the bit number of the batch number is the same as the target bit number;
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 one 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 consecutive N-bit identical numbers 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 by using a check code algorithm; wherein the check code is used for verifying the authenticity of the credential code;
adding the check code into the credential code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding the first character string into the credential 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 string includes: letters, numbers, or a combination 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 obtaining a verification request of the to-be-verified redemption code, wherein the verification request comprises the to-be-verified redemption code;
Determining a first credential 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;
if the first check code is different from the second check code, determining that the first credential code of the to-be-verified redemption code is wrong.
A third aspect of the present invention provides a credential code processing device, 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 as in any of the previous 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 as described in any one of the preceding embodiments.
In summary, the present invention provides a method, an apparatus, and a storage medium for processing a credential code, where the method includes: acquiring the target bit number and the batch number of the credential code to be generated; generating at least one random number according to the target bit number; adding at least one batch number to at least one random number to obtain a credential code. The credential code processing method, the credential code processing device and the storage medium can generate credential codes with different digits in a random number mode according to different digits and batch numbers, so that the security of the credential codes is ensured, and meanwhile, the generation efficiency of the credential codes is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the description below are only some embodiments of the invention, and that other drawings can be obtained according to these drawings without inventive faculty for a person skilled in the art.
FIG. 1 is a flow chart illustrating an embodiment of a credential code processing method according to the present invention;
FIG. 2 is a flowchart illustrating an embodiment of a credential code processing method according to the present invention;
FIG. 3 is a flowchart illustrating an embodiment of a credential code processing method according to the present invention;
FIG. 4 is a flowchart illustrating an embodiment of a credential code processing method according to the present invention;
FIG. 5 is a flowchart illustrating an embodiment of a credential code processing method according to the present invention;
FIG. 6 is a flowchart illustrating an embodiment of a credential code processing method according to the present invention;
FIG. 7 is a schematic diagram illustrating an embodiment of a credential code processing device of the present invention;
FIG. 8 is a schematic diagram illustrating an embodiment of a credential code processing device.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terms "first," "second," "third," "fourth" and the like in the description and in the claims and in the above drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented, for example, 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 scheme of the invention is described in detail below by specific examples. The following embodiments may be combined with each other, and some embodiments may not be repeated for the same or similar concepts or processes.
FIG. 1 is a flowchart illustrating an embodiment of a credential code processing method according to the present invention. As shown in fig. 1, the credential code processing method provided in this embodiment includes:
S101: the target bit number and the batch number of the credential to be generated are obtained.
Specifically, the execution body of the credential code processing method provided in this embodiment may be an electronic device having a related data processing function, for example: computers or servers, etc.; alternatively, it may 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 lot 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 can be included in the credential code provided by the credential code manager 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 "1111111". The batch number refers to batch information of the currently generated credential codes, and since the credential codes are generated in order of batches, the credential codes are stored in the database for use after one batch of credential codes are generated at a time. When the number of the credential codes in the database is smaller than the preset threshold, the credential codes of a batch are 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, such as a lot number of 00 for the first lot verification code, a lot number of 01 for the second lot verification code, and so on.
S102: generating at least one random number according to the target bit number, wherein the sum of the bit number of the at least one random number and the bit number of the batch number is the same as the target bit number.
Specifically, in S102, at least one random number is generated from the number of bits of the credential code determined in S101. In order to carry the lot number in the credential 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 credential code and the number of bits of the lot number. For example: if the number of bits of the target determined in S101 is 10 and the number of batches is 01, that is, the number of bits of the batch number is 2, the number of bits of at least one random number to be generated in S102 should be 8, and combining the at least one random number with the batch number can obtain the credential code finally generated in this embodiment.
In one possible implementation, at least one random number is generated in S102, and after determining the number of bits of the random number, the natural number corresponding to the number of bits may be used as the generated at least one random number. For example: if it is determined that the number of bits of at least one random number to be generated should be 8 bits, it can be determined that at least one natural number of 8 bits is 10000000 and 99999999 is the at least one random number.
Optionally, in the above embodiment, a check code of one bit may be further used in the credential code to verify the credential code, and then when at least one random number is generated, the number of bits of the check code needs to be further subtracted, and then at least one 7-bit natural numbers 1000000 and 9999999 are used as the at least one random number.
Further, in this embodiment, after determining at least one random number in S102, a random number having N consecutive identical digits in the at least one random number is deleted, where N is a positive integer less than or equal to the digits of the random number.
Specifically, since the determined random number is added to the credential code in this embodiment, if the random number has consecutive identical numbers, for example, a random number such as "1100000", the random number has a great risk of being enumerated, and the thief of the credential code can steal the credential code only by knowing the first two digits and then through consecutive "0". Therefore, although at least one random number is determined by random generation in the present embodiment, it is impossible to use random numbers with too many numbers that are continuously identical among random numbers as random numbers for subsequently generating credential codes.
For example: in one possible implementation, again taking the natural numbers 1000000 and 9999999 of 7 bits as an example, N can be specified as 3. In this embodiment, it is necessary to delete all natural numbers including consecutive 3 identical numbers, such as "1000000" or "1234555", from among the 7-bit natural numbers, to obtain at least one random number from which the repetition is removed: 1001001, 1001002, 1001003 … ….
S103: at least one batch number is added to the random number to obtain at least one credential 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 one possible implementation manner of S103, the batch number is split into two parts, and the batch numbers of the two parts are added to the beginning and the end of the random number respectively, so as to obtain the credential code. For example: when the lot number is a two digit number "10", the lot number can be split into "1" and "0". And adds "1" and "0" to the random number "1001001" to give "110010010". Finally, since the verification code of the credential code is also included in this example, the verification code can be added after the verification code is calculated according to the 9-bit credential code "110010010", and finally the 10-bit credential code is obtained. In the same manner as this example, after adding the at least one random number determined in S102 to the batch number, at least one credential code can be finally obtained, the credential code generation operation is completed, and the credential code can be stored in the database for later use.
In summary, in the credential code processing method provided in this embodiment, credential codes with different digits can be generated in a random number manner according to different digits and batch numbers. Compared with the credential code with fixed digits in the prior art, the credential code with more flexible digits can be generated, so that the credential code security is ensured, and meanwhile, the generation efficiency of the credential code is improved. Meanwhile, the embodiment adopts a random number mode to generate the credential codes, so that more credential codes can be generated in a shorter time, and the generation efficiency can be improved in the batch generation process of the credential codes unlike the numerical mode of independently determining each bit in each credential code in the prior art.
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 credential codes and their check codes may be referred to as redemption codes. The redemption code is used to verify the authenticity of the credential code therein by its verification code in use of the subsequent credential code.
Specifically, after S103, a check code of the credential code may also be calculated for each generated credential code by a check code algorithm; and adding the calculated check code into the credential code to obtain the redemption code. And (3) carrying out the calculation on the at least one credential code determined in the step (S103) to finally obtain at least one exchange code, and storing the exchange code into a database for later use.
FIG. 2 is a flowchart illustrating an embodiment of a credential code processing method according to the present application. One possible implementation method of the check code algorithm in the above embodiment is shown in fig. 2, where the check code algorithm includes:
s201: and adding the first character string into the credential code to obtain a character string group.
Specifically, in order to calculate the verification code of the credential code, a first character string is first added to the credential code. The first string may be a unique string provided by a credential manager, and only a person or device associated with the verification code calculation may acquire the first string and perform subsequent calculations based on the fixed first string.
Preferably, the first character string in each embodiment of the present application includes: letters, numbers, or a combination of letters and numbers. For example: in one possible implementation of the embodiment, the first string is set to be a combined string of letters and numbers of 6e1fd6ebb a, and then the first string needs to be added to the credential code "110010010" in S201. Alternatively, after the first string is added to the credential code, the credential code and the first string may be spliced to obtain a string group "1100100106e1fd6ebb a".
S202: converting the character string group into an AscII array;
subsequently, since the character string set determined in S201 has both numerals and letters, the above character string set is required to be converted into the form of AscII code to form an AscII array in S202. For example: the string set determined in S201 may be converted into an AscII array of "4949484849484849485410149102100541019898525697" in S202 according to a conversion rule of AscII codes.
S203: carrying out weighted summation on the AscII array to obtain a check code index;
then, in order to further ensure the security performance of the AscII array, in this step, a weighted summation calculation needs to be performed on the AscII array, and a specific weighted value and a specific weighted manner can be set by a manager of the credential code, and only a person or a device related to the check code calculation can acquire a 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.times.c 20 72 16 18 4 48 12 56 36 …… 25 48 36 14
For example, as shown in table 1, one possible implementation of this step is to use the AscII array determined in the above step as the weight number a, arrange the AscII arrays in reverse order to obtain the weight factor b, and then pass through formula 2 b The weight c is calculated as%11=c. That is, the b power of 2 is subjected to a remainder operation with 11 to obtain a weight c. For example: for the weighted number a, the 7 th power of the weighted factor 2 is 128, and the sum of 128 and 11 is calculated to obtain 5 as the weight c of the weighted number a.
Then, each weighted digit a is multiplied by its corresponding weight c, and the sum of the products of all weighted digits and weights c is modulo-budgeted with 10 to obtain a check code index of 6.
S204: 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.
For example: table 2 shows a mapping relationship between check code indexes and check codes, wherein each check code index has a corresponding check code. The check code 6 calculated in S203 can finally determine that the check code is 3 from the map of table 6.
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, the check code may be inserted into an intermediate position, e.g., bit 4, of the credential code "110010010" to obtain the complete redemption code "1103010010".
In summary, in the credential code processing method provided in this embodiment, after the original credential code is generated, a check code for verifying the credential code is further obtained by calculating according to the credential code, and the check code is inserted into the credential code to obtain a final usable exchange code. Particularly, letters or a combination of numbers and letters can be used in the first character string in the process of generating the check code, so that digits are not only used as the check code, and the accuracy of the check code calculated by the check code is further improved compared with the calculation mode of the pure-digit check code in the prior art.
Further, on the basis of calculating the check code by the credential code in the above embodiment, the present embodiment further provides a processing method of the credential code, for verifying the check code of the credential code in redemption, specifically, as shown in fig. 3, the method includes:
s301: acquiring a verification request of a to-be-verified redemption code, wherein the verification request comprises the to-be-verified redemption code;
s302: determining a first credential code and a first check code in the redemption code to be verified;
s303: calculating a second check code of the first credential code by 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 credential code of the to-be-verified redemption code is wrong;
s306: if the first check code is the same as the second check code, continuing to verify the first credential code of the redemption code to be verified.
Specifically, in this embodiment, in order to improve the exchange efficiency of the credential code in the redemption code, after receiving the verification request for verifying the redemption code in S301, the first credential code and the first verification code in the redemption code are first extracted in S302. And calculates a second check code through a check code algorithm for the extracted first credential code in S303 by the embodiment shown in fig. 2. If the first credential 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 the two check codes are different, it can be determined in S305 that the first credential code in the redemption code is wrong, and the check of the credential code can not be performed any more; if the two are the same, further verification of the first credential code in S306 is performed.
Therefore, in the verification method for the exchange code provided in this embodiment, whether the verification code of the credential code is correct or not can be calculated preferentially during exchange, and the credential code can be considered to be incorrect by the error of the verification code and returned to the exchange failure. And when the check code is correct, searching the database. Compared with the prior art that each credential code needs to enter a search database during verification, the method reduces the calculation amount for searching in the database and improves the speed and performance of the verification process of the redemption code.
In summary, the credential code processing method provided in this embodiment can verify the check code based on the check code algorithm used in the generation of the check code, and if the check code fails to pass, the credential code can be determined to be incorrect without continuing to verify the credential code, so that the computing pressure of the verification of the credential code on the server is improved by a faster, effective and simple check code verification method.
Further, based on the above embodiment, the present application also provides a flowchart for applying the credential code processing method of the present application to a specific operation of a server in an actual credential code generating server. An overall flow example of a specific application of the credential code processing method of the present application is described below 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 code bits to be generated needs to be specified first.
TABLE 3 Table 3
Fields Description of the application
code Enumerating values stored in a database
name Combination of number of credential code and credential code type (letter, number, letter + number)
initBatchNum Generating initial value of batch number of credential code
initialCodeKey Key of initial credential code in cache
availableCodeKey Key in cache for available credential code
desc Enumeration value description
Table 3 shows a specific implementation example of an enumeration configuration in which a field code in the code is used to represent the manner in which the credential code was determined, e.g., 10 bits when code is 1 and 12 bits when code is 2. The field name is used to determine whether the credential code to be determined is an alphanumeric or numeric or a combination of alphanumeric and numeric. The field initbachnum is used to represent the initial value of the batch number of the generated credential code. The field initialCodeKey is used to indicate the cache identity (key) of the initial credential code in the cache. The field availablecode key is used to represent a cache identification (key) of the available credential code in the cache. The field desc may add a description of the credential code as remark information.
Then, as shown in fig. 4, after the task of generating the initial credential code is triggered by the timer, firstly, the enumeration configuration of the number of digits of the generated credential code is read, and the number of the initial credential code in the cache is read through a field initial codekey in the enumeration configuration, and if the number is greater than 0, the task is directly ended after the initial credential code in the cache is not put in storage.
If the initial credential code quantity is equal to 0, the attribute availablecode key in the enumeration configuration is read, the available credential code quantity in the cache is read through the attribute, the unused credential code quantity in the database is counted through the enumeration attribute code, the available credential code quantity in the cache and the unused credential code quantity in the database are added, the summation result is compared with a threshold value codeMinAvlQty, if the summation result is larger than the threshold value codeMinAvlQty, the available credential code is sufficient, the task is directly ended without generation.
When the summation result is smaller than the threshold codeMinAvlQty, an initial credential code needs to be generated. Acquiring an enumeration attribute code, inquiring the maximum batch number of the enumeration corresponding voucher code in the database through the attribute, adding 1 to the batch number to obtain the batch number of the generated voucher if the batch number exists, and taking the attribute initbachnum in the enumeration configuration as the batch number of the generated voucher if the maximum batch number does not exist in the database.
After the batch number is acquired, an enumeration attribute name is acquired, the number of digits of the credential code to be generated is acquired through interception, and the formula is adopted: 10 (number of credential bits-number of lot number bits-number of check bits-first bit), the initial credential code start value is calculated. And multiplying the initial value by 10 and subtracting 1 to obtain the ending value of the initial credential code.
And circularly processing numbers between the starting value and the ending value, and performing the following operations: firstly, in order to reduce the cracking probability of the credential code, in the cycle, the digits of the third serial number are discarded, for example 111,222 … …, then the first digit of the batch number is spliced in front of the digits, the rest digits are spliced behind the digits, finally an initial credential code is formed, and the initial credential code is put into a set in sequence. After the circulation is finished, the sequence of the initial credential codes in the collection is disturbed by a shuffling algorithm, the collection after the disturbance of the sequence is stored in a cache in batches, a redis is used as a cache system and a list data structure is used, so that the access and the quantity statistics of the credential codes are facilitated, and after all the storage is finished, the task execution of the initial credential codes is finished.
The following also describes the generation of an initial credential code using a 10-bit digital credential code, which includes: 1. initializing the configuration. Acquiring credential code length enumeration: tenjdigital (1, "10_1",10, "init_tenjdigital", "avl _tenjdigital", "10-bit pure number"); acquiring a threshold codeMinAvlQty:1000; and acquiring the check code bit number of the credential code to be 1. 2. Caching keys through an initial credential code: init_ten_digital acquires the initial number initQty of credential codes in the cache, and if initQty is greater than 0, the task is directly ended. 3. Assuming the initQty is equal to 0, the key is cached by the available credential code: avl _ten_digital acquires the available number avlQty of credential codes in redis; then, on condition that the enumeration code and credential code usage status (unused), pass sql: SELECT COUNT (1) FROM xxx where length _type=1and is_used=1, the number of available credential codes dbAvlQty in the statistics database, avlQty and dbAvlQty are added, the resulting sum is compared with minAvlQty, if greater than minAvlQty, the task ends. If it is less than minAvlQty, the task continues to execute downward. 4. On the condition of enumerating codes, by sql: SELECT max (batch_number) from xxx where length _type=1 gives the maximum of the batch number maxBatchNum in the database, here the enumeration initbachnum is used assuming maxBatchNum is empty: 10 is the batch number generated this time. 5. Acquiring the length of the credential code to be generated, which is configured in enumeration: 10, calculating at least a start value of the certificate: 10 (10-2 (lot number) -1 (check code number) -1 (first bit))= 1000 000, end value: start value 10-1= 9 999 999. 6. The numbers of cycles 1000 000 and 9 999 999, after discarding the triple numbers therein, are 1001001, 1001002, 1001003 … … to splice the lot number 10 first to the first digit, and 0 splice to the end to get: 110010010, 110010020, 110010030 … … can thus generate 850w initial credential codes at a time, making up a collective list. 7. And adding the list obtained by the above into the redis cache in batches by taking init_ten_digital as a key.
It should be noted that, in the credential code processing method provided in the embodiment of fig. 4, the generated initial credential code is the same as the credential code generated in fig. 1. The difference is that in practical application, the credential code generated by the credential code processing method of the present embodiment is not the final credential code, and may be referred to as the initial credential code in some practical applications, because subsequent processing such as uploading the server and adding the check code is required after the credential code is generated in the cache.
Further, after the initial credential code is generated by the embodiment shown in fig. 4, in order to obtain the final credential code, a check code of the credential code needs to be calculated, and the check code and the credential code are combined into a usable exchange code. Therefore, an embodiment of the present application further provides a method for generating a check code of the credential code based on the foregoing, so as to add the initial credential code generated in the memory in fig. 4 to the check code and send the initial credential code to the database for encryption and storage.
In order to implement the calculation configuration of the check code, the table structure of the storage code table of the credential code can be configured as well.
TABLE 4 Table 4
Field name Type(s) Length of Description of the application
length_type tinyint 3 Credential code type enumeration value
batch_number int 10 Batch number
code varchar 128 Credential code encryption value
is_used tinyint 1 Whether or not to use
For example: table 4 shows a memory table of one possible credential code, where the field length_type is the same as the field code in table 3. The field batch_number: the batch number is spliced at the head and the tail of the initial credential code, so the initial credential code head is the batch number head, then the number of bits obtained by subtracting the initial batch number from the head is the initial position index of the last few bits of the batch number in the initial credential code by using the initial credential code number, after the index is obtained, the last few bits of the batch number are intercepted from the initial credential code, and the batch number is obtained after the batch number head and the last few bits 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 of a credential code processing method according to an embodiment of the present invention. In fig. 5, the task of storing the credentials to the database may also be triggered by a timed task, in which the credentials and the check code are combined into a redemption code and uploaded to the database after the check code is calculated from the credentials. The number of the initial credential codes in the rediss can be read through the field initial CodeKey, and if the number is equal to 0, the task is ended. If the number is greater than 0, the characteristics that the redisRPOP command can remove and return the tail elements of the list key are utilized, the RPOP command is circularly called to take out the initial credential code, and after the initial credential code is taken out, each field of the credential storage code table is assigned.
The following step of obtaining a final redemption code from the initial voucher code is also illustrated with a 10-digit digital voucher code, the step comprising: 1. the initial credential code 110010010 is fetched using the redisrpop command. 2. Setting a credential code table field value length_type: ten digit type code=1. 2. batch_number: the first bit is the first bit of the credential code 110010010, namely 1, and the remaining bit acquisition mode: firstly, using the formula: the initial credential code digit number (9) is the digit number (1) of the initial batch number divided by the first digit, so that the number of the rest digits of the batch number is obtained at the index position 8 of the initial credential code, and the number of digits after the index 8 is intercepted to obtain the last digit 0 of the batch number. And splicing the batch number 1 and the tail bit 0 to obtain a batch number 10. 3. code: firstly, to improve the security of the key, the key is set to be a character string mixed by letters and numbers preferentially, and the key is assumed to be: 6e1fd6ebb a, the initial credential 110010010 and the check code calculation key are spliced and then are converted into AscII:4949484849484849485410149102100541019898525697. the complete redemption code 1103010010 may then be obtained by calculating the verification code as in the example shown in fig. 2, in combination with tables 1 and 2. 4. And adding the complete exchange codes into the set, and storing the complete exchange codes into a database together after a certain number of the exchange codes are reached, so that the exchange codes are stored into the database from a cache for later selection and use.
In summary, through the embodiments of fig. 4 and 5, the redemption code including the credential code and the verification code can be finally obtained and stored in the database of the server, and it can be understood that multiple batches of redemption codes are stored in the server. In actual use, in order to improve the use efficiency of the redemption code, the redemption code to be used each time is stored in the cache from the database, so that the redemption code can be determined more quickly from the cache.
For example: FIG. 6 is a flowchart illustrating an exemplary credential processing method according to an embodiment of the present invention. The flow of extracting redemption codes from the database into the cache is shown in figure 6. When the credential code is stored in the database, a certain number of credential codes can be pushed into the memory redis to improve the performance when issuing the credential code because of large data volume of the credential code table, and the credential code can be directly obtained from the redis when issuing the credential code. To ensure high availability of the system, a timing task is used to monitor 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 is queried from the credential code table and pushed into the redis. The method comprises the following specific steps: firstly, reading a bit number type enumeration attribute availablecode, and reading the number of available credential codes in rediss according to the cache key, wherein if the number of the available credential codes is greater than or equal to a threshold value minNumInCache, the task is directly ended; otherwise, the task continues to execute downwards, a batch of unused credential codes are queried from the credential code table, pushed into redis after being queried, and then the state of the batch of credential codes in the table is updated and used. And executing the operation circularly until the number of the credential codes in the redis is larger than a threshold value minNumInCache.
FIG. 7 is a schematic diagram of an embodiment of a credential code processing device. As shown in fig. 7, the credential code processing device provided in this embodiment includes: an acquisition module 701 and a processing module 702. The acquiring module 701 is configured to acquire a target number of bits and a lot number of a credential to be generated; the processing module 702 is configured to generate at least one random number according to the target number of bits, where the sum of the number of bits of the at least one random number and the number of bits of the batch number is the same as the target number of bits; the processing module 702 is further configured to add the batch number to the at least one random number to obtain at least one credential code.
The credential code processing device provided in this embodiment may be used to execute the credential code processing method shown in fig. 1, and the implementation method and principle thereof are the same and will not be described again.
Optionally, the processing module 702 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, so as to obtain the credential code.
Optionally, the processing module 702 is further configured to delete a random number, where N consecutive digits are identical, from at least one random number, where N is a positive integer less than or equal to the number of digits of the random number.
Optionally, the processing module 702 is further configured to calculate a check code of the credential code by a check code algorithm; wherein the check code is used for verifying the authenticity of the credential code;
Adding the check code into the credential code to obtain a redemption code;
wherein the check code algorithm comprises:
adding the first character string into the credential 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.
Optionally, the first character string includes: letters, numbers, or a combination of letters and numbers.
FIG. 8 is a schematic diagram illustrating an embodiment of a credential code processing device. The device shown in fig. 8 further comprises, on the basis of the embodiment shown in fig. 7: a verification module 801. The verification request is used for acquiring the to-be-verified redemption code, and the verification request comprises the to-be-verified redemption code; determining a first credential code and a first check code in the redemption code to be verified; calculating a second check code of the credential code through a check code algorithm; if the first check code is different from the second check code, determining that the credential code of the to-be-verified redemption code is wrong.
It should be noted that, in the embodiment of the present application, the division of the modules is schematic, which is merely a logic function division, and other division manners may be implemented in actual implementation. The functional modules 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 may be integrated into one module. The integrated modules may be implemented in hardware or in software functional modules.
The integrated modules, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to execute all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In the above embodiments, it may be implemented in whole or in part 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. When the computer program instructions are loaded and executed on a computer, the processes or functions in accordance with embodiments of the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.) means from one website, computer, server, or data center. Computer readable storage media can be any available media that can be accessed by a computer or data storage devices, such as servers, data centers, etc., that contain an integration of one or more 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)), etc.
The invention also provides a credential code processing device, which comprises: a processor, a memory and a computer program; wherein a computer program is stored in a memory and configured to be executed by a processor, the computer program comprising instructions for performing the credential code processing method as in any of the previous embodiments.
The present invention also provides a storage medium storing a computer program that causes a server to execute the credential code processing method as in any one of the foregoing embodiments.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.

Claims (5)

1. A method for processing a credential code, comprising:
obtaining the target bit number and the batch number of the credential code to be generated, wherein the batch number is the batch information of the credential code to be generated and comprises at least two bits;
generating at least one random number according to the target bit number, wherein the sum of the bit number of the at least one random number and the bit number of the batch number is the same as the target bit number;
adding the batch number into the at least one random number to obtain at least one credential code;
the adding the batch number to the random number to obtain a credential code comprises:
splitting the batch number into two parts, and respectively adding the batch numbers of the two parts into the beginning and the end of the random number to obtain the credential code;
after the generating at least one random number according to the target bit number, the method further comprises:
deleting random numbers with continuous N digits which are identical in number in the at least one random number, wherein N is a positive integer which is less than or equal to the digits of the random numbers;
after the batch number is added into the random number to obtain the credential code, the method further comprises the following steps:
calculating a check code of the credential code through a check code algorithm; wherein the check code is used for verifying the authenticity of the credential code;
Adding the check code into the credential code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding the first character string into the credential 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;
determining a check code corresponding to the check code index according to a mapping relation, wherein the mapping relation comprises a corresponding relation between at least one check code index and at least one check code;
the first character string includes: letters or a combination of letters and numbers.
2. The method as recited in claim 1, further comprising:
acquiring a verification request of a to-be-verified redemption code, wherein the verification request comprises the to-be-verified redemption code;
determining a first credential 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;
if the first check code is different from the second check code, determining that the first credential code of the to-be-verified redemption code is wrong.
3. A credential code processing device, comprising:
the system comprises an acquisition module, a verification module and a verification module, wherein the acquisition module is used for acquiring the target bit number and the batch number of the credential code to be generated, the batch number is the batch information of the credential code to be generated, and the batch number comprises at least two bits;
The processing module is used for generating at least one random number according to the target bit number, and the sum of the bit number of the at least one random number and the bit number of the batch number is the same as the target bit number;
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;
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;
the processing module is further used for deleting random numbers with continuous N digits identical to the at least one random number;
the processing module is also used for calculating the check code of the credential code through a check code algorithm; wherein the check code is used for verifying the authenticity of the credential code;
adding the check code into the credential code to obtain a redemption code;
the check code algorithm comprises the following steps:
adding a first character string into the credential code to obtain a character string group, wherein the first character string comprises: letters or a combination of letters and numbers;
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.
4. A credential code processing device, 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 as claimed in claim 1 or 2.
5. A storage medium storing a computer program that causes a server to execute the credential code processing method of claim 1 or 2.
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 CN111723360A (en) 2020-09-29
CN111723360B true 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)

Families Citing this family (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
CN113408246A (en) * 2021-06-30 2021-09-17 商盟商务服务有限公司 Method, device and system for acquiring single number
CN113318456B (en) * 2021-06-30 2024-04-02 完美世界(重庆)互动科技有限公司 Data credential system, method, apparatus, and medium

Citations (7)

* 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
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

Family Cites Families (1)

* 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

Patent Citations (7)

* 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
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

Also Published As

Publication number Publication date
CN111723360A (en) 2020-09-29

Similar Documents

Publication Publication Date Title
CN111723360B (en) Credential code processing method, device and storage medium
CN106649346B (en) Data repeatability checking method and device
US9619657B2 (en) Method and apparatus for storing redeem code, and method and apparatus for verifying redeem code
CN110489466B (en) Method and device for generating invitation code, terminal equipment and storage medium
CN108228799B (en) Object index information storage method and device
EP3072076A1 (en) A method of generating a reference index data structure and method for finding a position of a data pattern in a reference data structure
CN112487253B (en) User invitation code generation method, verification method, device, equipment and storage medium
US20220004621A1 (en) Data recovery through reversal of hash values using probabilistic data structures
CN111209341B (en) Data storage method, device, equipment and medium of block chain
Chen et al. A high-throughput FPGA accelerator for short-read mapping of the whole human genome
CN108234122A (en) Token method of calibration and device
CN110532284B (en) Mass data storage and retrieval method and device, computer equipment and storage medium
CN110941831B (en) Vulnerability matching method based on slicing technology
CN104125254A (en) Method and system for obtaining platform user data
CN115292737B (en) Multi-keyword fuzzy search encryption method and system and electronic equipment
CN109213972B (en) Method, device, equipment and computer storage medium for determining document similarity
CN116401229A (en) Database data verification method, device and equipment
CN106250440B (en) Document management method and device
KR102375511B1 (en) Document storage management server for performing storage processing of document files received from a client terminal in conjunction with a plurality of document storage and operating method thereof
CN110309235B (en) Data processing method, device, equipment and medium
CN117076509B (en) Data duplicate checking method, device, equipment and storage medium
CN111782645A (en) Data processing method and device
CN115935429B (en) Data processing method, device, medium and electronic equipment
CN116089491B (en) Retrieval matching method and device based on time sequence database
CN112860712B (en) Block chain-based transaction database construction method, system and electronic equipment

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