CN110675199A - Method for generating non-repeated preference code based on hash algorithm - Google Patents
Method for generating non-repeated preference code based on hash algorithm Download PDFInfo
- Publication number
- CN110675199A CN110675199A CN201910951072.7A CN201910951072A CN110675199A CN 110675199 A CN110675199 A CN 110675199A CN 201910951072 A CN201910951072 A CN 201910951072A CN 110675199 A CN110675199 A CN 110675199A
- Authority
- CN
- China
- Prior art keywords
- code
- preference
- length
- codes
- prefix
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q30/00—Commerce
- G06Q30/02—Marketing; Price estimation or determination; Fundraising
- G06Q30/0207—Discounts or incentives, e.g. coupons or rebates
- G06Q30/0239—Online discounts or incentives
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/215—Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2255—Hash tables
Abstract
The invention discloses a method for generating a non-repetitive discount code based on a hash algorithm, which comprises the following steps: A. acquiring parameter information which is submitted by a user from an application operation interface and needs to generate a discount code; B. after receiving the application request information, preprocessing the acquired parameter information; C. calculating the length of the prefix of the preference code, and calculating the length of the prefix of the preference code and the length of the preference code to calculate the random bit length of the preference code; D. and submitting the preference code prefix, the preference code quantity and the preference code random bit length to a dynamic character string generator for data processing to obtain the final required preference code. The method can effectively solve the problems of high repetition rate, overlong length, low generation efficiency, inconvenience in use of users and the like of a preferential code generation mode.
Description
Technical Field
The invention relates to the technical field of preferential code generation, in particular to a method for generating a non-repetitive preferential code based on a hash algorithm.
Background
At present, a variety of promotion methods are used in more and more internet applications, and the promotion code is very common in the promotion method. The use of the preferential codes brings benefits to merchants and benefits to users. Under the background, consumers consider obtaining the benefit code to achieve the purpose of low-price shopping more in shopping, and the use amount of the benefit code is continuously increased along with the increasing of user groups. However, most of the prior coupon code generation methods adopt the mode of recording access and pickup conditions at the user side to generate new coupon codes, and the coupon codes generated by the method have the problem of high repetition rate. To solve this problem, the length of the code is increased, which makes the user input difficult; or the generated data in the database is queried to remove repeated codes, so that the server is stressed too much when the number of the server accessing people is large, the reaction at the user side is delayed, and the user experience is influenced.
Disclosure of Invention
The invention aims to overcome the defects in the background art, provides a method for generating a non-repetitive preference code based on a hash algorithm, and can effectively solve the problems of high repetition rate, overlong length, low generation efficiency, inconvenience for users and the like in a preference code generation mode.
In order to achieve the technical effects, the invention adopts the following technical scheme:
a method for generating a non-repetitive preference code based on a hash algorithm comprises the following steps:
A. acquiring parameter information which is submitted by a user from an application operation interface and needs to generate a discount code; wherein, the parameter information at least comprises a preference code prefix, a preference code quantity and a preference code length;
B. after receiving the application request information, preprocessing the acquired parameter information to ensure that the data information is effective;
C. calculating the length of the prefix of the preference code, and calculating the length of the prefix of the preference code and the length of the preference code to calculate the random bit length of the preference code;
D. and submitting the preference code prefix, the preference code quantity and the preference code random bit length to a dynamic character string generator for data processing to obtain the final required preference code.
Further, the preprocessing the parameter information in the step B includes:
B1. processing the prefix of the preferential code, and enabling the prefix of the preferential code to only contain capital and lower case letters and numbers through regular matching of letters and numbers;
B2. processing the number of the preferential codes, and enabling the number of the preferential codes to be a legal positive integer through regular matching numbers;
B3. processing the preferential code length to make the preferential code length be a legal positive integer, and the code quantity which can be generated by the minimum value is in accordance with the requirement of the preferential code quantity
Further, in the step C, the random bit length of the benefit code is the benefit code length — the benefit code prefix length.
Further, the dynamic string generator performs the following processing on the received data:
s1, creating a random factor;
s2, carrying out hash operation on the random factor to obtain a random code with the length of 32 characters;
s3, binary operation is carried out on the random code to obtain binary data, 64 characters are used for representing the binary data, and finally a character string represented by the 64 characters is obtained;
and S4, processing the character string to obtain a preferential code meeting the requirement.
Further, in step S4, the following processing is specifically performed on the character string:
s4.1, removing characters except letters and numbers in the character string to obtain a character string B;
s4.2, performing code confusion on the character string B to reduce the character identity rate and obtain a character string C;
s4.3, splitting the character string C into a plurality of character strings D1, D2 and … Dn which are consistent with the random bit length of the discount codes transmitted to the dynamic character generator;
and S4.4, splicing the preference code prefix with the obtained multiple character strings D1, D2 and D3 … to obtain the final preference codes D1 ', D2 ' and … Dn '.
Further, the method also includes step S5: and putting the obtained preference codes into a hash table, and excluding the same preference codes which possibly exist to obtain final non-repeated preference codes.
Further, the method also includes step S6: steps S1 through S5 are repeated until the number of generated offer codes reaches the number of offer codes input by the user.
Compared with the prior art, the invention has the following beneficial effects:
the method for generating the unrepeated coupon code based on the hash algorithm effectively avoids the repeatability of the coupon code, improves the efficiency of generating the unique code, effectively shortens the length of the coupon code and achieves the aim of facilitating the manual input of a user by innovating the generation mode of the coupon code.
Drawings
Fig. 1 is a schematic flow chart of a method for generating a non-repetitive coupon code based on a hash algorithm according to the present invention.
Detailed Description
The invention will be further elucidated and described with reference to the embodiments of the invention described hereinafter.
Example (b):
the first embodiment is as follows:
as shown in fig. 1, a method for generating a non-repetitive coupon code based on a hash algorithm includes the following steps:
step 1, a user inputs and submits a preference code prefix, a preference code quantity, a preference code length and the like on an operation interface.
And 2, acquiring the parameter information which is submitted by the user and needs to generate the discount codes, wherein the acquired parameter information at least comprises a prefix of the discount codes, the number of the discount codes and the length of the discount codes.
And step 3, after receiving the application request information, preprocessing the data to ensure that the preference code prefix, the preference code quantity and the preference code length meet the requirements.
Specifically, in this embodiment, the preprocessing the data specifically includes:
and processing the preference code prefix to ensure that the preference code prefix only contains upper and lower case letters and numbers, if the letter and the number are matched regularly, returning an exception if other characters are contained, and requiring the user to submit the data again.
And processing the number of the preferential codes to ensure that the number of the preferential codes is a legal positive integer, if the number is matched by a regular matching number, if the number is not a positive integer, returning to an abnormal state, and requiring the user to submit data again.
And processing the length of the preferential codes to ensure that the length of the preferential codes is a legal positive integer, and the code quantity which can be generated by the minimum value meets the requirement of the number of the preferential codes, if not, returning an exception to require the user to submit the data again.
If the user submits the data with the benefit code length of 2 and the benefit code number of 10000, the maximum producible number of the length is 64 x 64 to 4096 which is less than the benefit code number 10000 needing to be generated, so the data is abnormal and the user needs to submit the data again.
And 4, calculating the prefix length of the preference code, and calculating the random bit length of the preference code by calculating the calculation result and the length of the preference code.
Specifically, calculating the prefix length of the preferential code, namely calculating the prefix character number of the preferential code, wherein if the prefix of the preferential code is CH, the prefix length of the preferential code is 2; and if the prefix of the preference code is CHO, the prefix length of the preference code is 3 and the like. The operation of the preference code prefix length and the preference code length is specifically to perform mathematical subtraction operation on the preference code length and the value of the preference code prefix character obtained by the number calculation to obtain the preference code random bit length, namely the preference code random bit length is equal to the preference code length-the preference code prefix length.
Specifically, in this embodiment, the preference code prefix is input into CH, and the preference code length is input into value 8. The prefix value of the preferential code is 2 according to the calculation rule; namely, the random bit length of the preferential code is 8-2-6.
And 5, transmitting the preference code prefix, the number of the preference codes and the random bit length of the preference codes to a dynamic character string generator to obtain the final required preference codes.
Specifically, in this embodiment, the dynamic string generator specifically includes the following operations:
and 5.1, creating a random factor by the dynamic character string generator.
Specifically, in this embodiment, the linear congruence generator generates a random number through a clock microsecond seed to obtain a random factor, and specifically, a final result is related to a current clock microsecond number when the call is first called.
And 5.2, performing hash operation on the random factor obtained in the step 5.1 to obtain a random code with the length of 32 characters.
And 5.3, performing binary operation on the random code of the 32 characters obtained in the step 5.2 to obtain binary data, and expressing the binary data by using 64 characters to finally obtain a character string expressed by 64 characters. Specifically, in this embodiment, binary data is processed, each 3 bytes is divided into 4 groups, each group is exactly 6 bits, and 4 numbers are obtained as an index, and then table lookup is performed to obtain corresponding 4 characters, and finally a coded character string a is obtained;
specifically, in the present embodiment, the table is formed by capital letters, lowercase letters, numbers and an array of + and/or 64 characters, i.e., [ ' a ', ' B ', ' C ', ] a. -, ' a ', ' B ', ' C ',. a. -, '0', '1',. a. + ', '/' ].
Step 5.4, processing the character string A to obtain a favorable code meeting the requirement, which specifically comprises the following steps:
the first step is as follows: processing the character string A, removing characters except letters and numbers to obtain a new character string B;
the second step is that: carrying out code confusion on the character string B obtained in the last step, reducing the character identity rate and obtaining a new character string C;
the third step: splitting the character string C obtained in the last step into a plurality of character strings D1, D2 and D3 … which are consistent with the random bit length of the discount code transmitted to the dynamic character generator;
the fourth step: and splicing the preference code prefix with a plurality of character strings D1, D2 and D3 … obtained in the last step to obtain final preference codes D1 ', D2 ' and D3 ' ….
Specifically, when the concatenation is performed, the prefix of the coupon code and the generated character strings D1, D2, and D3 … are respectively connected together, and if the prefix of the coupon code is CH, and the generated character strings are abc, def, and ghi, the final coupon code after the concatenation is obtained as chbac, CHdef, and CHghi.
And 5.5, performing hash operation on the coupon codes D1 ', D2 ', D3 ' … obtained in the previous step, and then putting the coupon codes into a hash table to exclude the same coupon codes which may exist, so as to obtain final unrepeated coupon codes.
And 5.6, repeating the steps S5.1 to S5.5 until the generated number of the discount codes reaches the number of the discount codes input by the user.
It will be understood that the above embodiments are merely exemplary embodiments taken to illustrate the principles of the present invention, which is not limited thereto. It will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the spirit and substance of the invention, and these modifications and improvements are also considered to be within the scope of the invention.
Claims (7)
1. A method for generating a non-repeated discount code based on a hash algorithm is characterized by comprising the following steps:
A. acquiring parameter information which is submitted by a user from an application operation interface and needs to generate a discount code; wherein, the parameter information at least comprises a preference code prefix, a preference code quantity and a preference code length;
B. after receiving the application request information, preprocessing the acquired parameter information;
C. calculating the length of the prefix of the preference code, and calculating the length of the prefix of the preference code and the length of the preference code to calculate the random bit length of the preference code;
D. and submitting the preference code prefix, the preference code quantity and the preference code random bit length to a dynamic character string generator for data processing to obtain the final required preference code.
2. The method for generating non-repetitive preference codes based on the hash algorithm as claimed in claim 1, wherein the preprocessing the parameter information in the step B comprises:
B1. processing the prefix of the preferential code, and enabling the prefix of the preferential code to only contain capital and lower case letters and numbers through regular matching of letters and numbers;
B2. processing the number of the preferential codes, and enabling the number of the preferential codes to be a legal positive integer through regular matching numbers;
B3. and processing the length of the preference code to ensure that the length of the preference code is a legal positive integer, and the code quantity which can be generated by the minimum value meets the requirement of the number of the preference code.
3. The method for generating non-repetitive preference codes based on the hash algorithm as claimed in claim 2, wherein the length of the random bit of the preference code in step C is the length of the preference code-the prefix length of the preference code.
4. The method for generating non-repetitive preference codes based on the hash algorithm as claimed in claim 1, wherein the dynamic string generator performs the following processing on the received data:
s1, creating a random factor;
s2, carrying out hash operation on the random factor to obtain a random code with the length of 32 characters;
s3, binary operation is carried out on the random code to obtain binary data, 64 characters are used for representing the binary data, and finally a character string represented by the 64 characters is obtained;
and S4, processing the character string to obtain a preferential code meeting the requirement.
5. The method for generating non-repetitive preference codes based on the hash algorithm as claimed in claim 4, wherein the step S4 is specifically to perform the following processing on the character string:
s4.1, removing characters except letters and numbers in the character string to obtain a character string B;
s4.2, performing code confusion on the character string B to reduce the character identity rate and obtain a character string C;
s4.3, splitting the character string C into a plurality of character strings D1, D2 and … Dn which are consistent with the random bit length of the discount codes transmitted to the dynamic character generator;
and S4.4, splicing the preference code prefix with the obtained multiple character strings D1, D2 and D3 … to obtain the final preference codes D1 ', D2 ' and … Dn '.
6. The method for generating non-repetitive coupon codes based on the hash algorithm according to any one of claims 1 to 5, further comprising the step of S5: and putting the obtained preference codes into a hash table, and excluding the same preference codes which possibly exist to obtain final non-repeated preference codes.
7. The method for generating non-repetitive offer codes based on hash algorithm as claimed in claim 6, further comprising step S6: steps S1 through S5 are repeated until the number of generated offer codes reaches the number of offer codes input by the user.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910951072.7A CN110675199A (en) | 2019-10-08 | 2019-10-08 | Method for generating non-repeated preference code based on hash algorithm |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910951072.7A CN110675199A (en) | 2019-10-08 | 2019-10-08 | Method for generating non-repeated preference code based on hash algorithm |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110675199A true CN110675199A (en) | 2020-01-10 |
Family
ID=69080943
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910951072.7A Pending CN110675199A (en) | 2019-10-08 | 2019-10-08 | Method for generating non-repeated preference code based on hash algorithm |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110675199A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102752110A (en) * | 2011-04-19 | 2012-10-24 | 中国银行股份有限公司 | Dynamic password generating method and system |
KR101322837B1 (en) * | 2012-11-09 | 2013-10-28 | 국방과학연구소 | Optimal code-length finding method in variable-length pseudo-random code generator |
CN107169803A (en) * | 2017-05-27 | 2017-09-15 | 上海非码网络科技有限公司 | A kind of method, system and device, server for generating reward voucher in advance |
CN109117116A (en) * | 2017-06-26 | 2019-01-01 | 上海新飞凡电子商务有限公司 | Based on the random delivery of cargo code generating method from increasing sequence |
CN109522454A (en) * | 2018-11-20 | 2019-03-26 | 四川长虹电器股份有限公司 | The method for automatically generating web sample data |
CN110275695A (en) * | 2019-04-25 | 2019-09-24 | 武汉众邦银行股份有限公司 | Non-duplicate random code generating method, equipment, storage medium and device |
-
2019
- 2019-10-08 CN CN201910951072.7A patent/CN110675199A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102752110A (en) * | 2011-04-19 | 2012-10-24 | 中国银行股份有限公司 | Dynamic password generating method and system |
KR101322837B1 (en) * | 2012-11-09 | 2013-10-28 | 국방과학연구소 | Optimal code-length finding method in variable-length pseudo-random code generator |
CN107169803A (en) * | 2017-05-27 | 2017-09-15 | 上海非码网络科技有限公司 | A kind of method, system and device, server for generating reward voucher in advance |
CN109117116A (en) * | 2017-06-26 | 2019-01-01 | 上海新飞凡电子商务有限公司 | Based on the random delivery of cargo code generating method from increasing sequence |
CN109522454A (en) * | 2018-11-20 | 2019-03-26 | 四川长虹电器股份有限公司 | The method for automatically generating web sample data |
CN110275695A (en) * | 2019-04-25 | 2019-09-24 | 武汉众邦银行股份有限公司 | Non-duplicate random code generating method, equipment, storage medium and device |
Non-Patent Citations (1)
Title |
---|
严灿勋 著: "《英汉军事语料句子对齐研究》", 30 June 2015, 国防工业出版社 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11386271B2 (en) | Mathematical processing method, apparatus and device for text problem, and storage medium | |
US10515155B2 (en) | Conversational agent | |
Castelluccia et al. | When privacy meets security: Leveraging personal information for password cracking | |
CN104866478B (en) | Malicious text detection and identification method and device | |
CN104866985B (en) | The recognition methods of express delivery odd numbers, apparatus and system | |
CN107146112B (en) | Mobile internet advertisement putting method | |
CN109492233B (en) | Machine translation method and device | |
CN108418683B (en) | Carrier-free text steganography method based on Chinese character structural features | |
CN102737105A (en) | Dict-tree generation method and searching method | |
CN115296862B (en) | Network data safety transmission method based on data coding | |
CN107885716B (en) | Text recognition method and device | |
CN110750731B (en) | Method and system for removing duplicate of news public opinion | |
CN110675199A (en) | Method for generating non-repeated preference code based on hash algorithm | |
CN111312333B (en) | Method, apparatus, device and medium for improving BWT table look-up performance | |
CN110569499B (en) | Generating type dialog system coding method and coder based on multi-mode word vectors | |
US9235610B2 (en) | Short string compression | |
CN109361399A (en) | A kind of method, apparatus, equipment and storage medium obtaining byte sequence | |
CN104715022A (en) | Relevant searching method and device | |
JP2019087157A (en) | Word vector conversion apparatus, method and program | |
CN112329393A (en) | Method, equipment and storage medium for generating short code ID | |
CN111858862B (en) | Reply recommendation method, reply recommendation device and electronic equipment | |
JP2005004560A (en) | Method for creating inverted file | |
CN110825927A (en) | Data query method and device, electronic equipment and computer readable storage medium | |
CN112364368B (en) | Telephone number encryption storage method | |
CN115798517B (en) | Commodity searching method and system based on voice information characteristic data |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200110 |