CN113824807A - Invitation code generation method and device, electronic equipment and storage medium - Google Patents

Invitation code generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113824807A
CN113824807A CN202110255960.2A CN202110255960A CN113824807A CN 113824807 A CN113824807 A CN 113824807A CN 202110255960 A CN202110255960 A CN 202110255960A CN 113824807 A CN113824807 A CN 113824807A
Authority
CN
China
Prior art keywords
invitation code
length
array
invitation
generated
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
Application number
CN202110255960.2A
Other languages
Chinese (zh)
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 Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun 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 Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202110255960.2A priority Critical patent/CN113824807A/en
Publication of CN113824807A publication Critical patent/CN113824807A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/30Managing network names, e.g. use of aliases or nicknames
    • H04L61/3015Name registration, generation or assignment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention provides an invitation code generation method, an invitation code generation device, electronic equipment and a storage medium, wherein the method comprises the following steps: receiving an invitation code generation request of a user; generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generation request; according to the global unique identifier carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, carrying out scaling assignment, bitwise diffusion and bitwise confusion on the invitation code array based on the length of the character sequence used for the invitation code so as to enable the value of the element in the invitation code array to fall into the value interval [0, L ]1‑1]Wherein, basic data information corresponding to the length of the invitation code to be generated and the character sequence for the invitation code are configured in advance, L1Is the length of the character sequence for the invitation code; extracting characters corresponding to the values of each element of the invitation code array in the character sequence for the invitation codes,and determining a character string formed by the extracted characters as an invitation code of the user.

Description

Invitation code generation method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of information processing technologies, and in particular, to an invitation code generation method and apparatus, an electronic device, and a storage medium.
Background
Currently, there are several schemes for generating non-duplicated invitation codes that cannot be guessed:
firstly, after the invitation code is generated each time, whether the invitation code is repeated is determined by checking a database, and if the invitation code is repeated, the invitation code needs to be generated again. This method is extremely inefficient.
And secondly, taking the main key of the database as a unique key, performing scrambling or inserting operation, if the main key is 8000001, taking out the main key, generating N-bit (set according to requirements) random numbers or letters, and inserting the N-bit random numbers or letters into the main key value to form a string such as 8000E0V0S1D, thereby ensuring that invitation codes are not repeated. The method needs to pre-generate a large number of main keys at one time, increases complexity, and has the problem that the number of the main keys is insufficient after the user explosive growth.
And thirdly, the uniqueness of the invitation code is ensured by utilizing an algorithm. For example, the invitation code is generated by using a UUID algorithm, a SHA algorithm, an RC4 algorithm and the like, but the invitation code generated by using the UUID algorithm and the SHA algorithm is too long to be practical; however, the invitation code generated by the RC4 algorithm has symbols that do not belong to letters and numbers, is not suitable for use as an invitation code for users, has a problem of too long length, and is not practical enough.
Disclosure of Invention
In view of the above, an object of the present invention is to provide an invite code generation method, an invite code generation device, an electronic device, and a storage medium, which can improve the invite code generation efficiency, reduce the complexity, and control the length of the generated invite code.
In order to achieve the purpose, the invention provides the following technical scheme:
an invitation code generation method, comprising:
receiving an invitation code generation request of a user;
generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generation request;
according to the global unique identification id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, carrying out scaling assignment, bitwise diffusion and bitwise confusion on the invitation code array based on the character sequence length used for the invitation code so as to enable the element value in the invitation code array to fall into the value range [0, L ]1-1]Wherein, basic data information corresponding to the length of the invitation code to be generated and the character sequence for the invitation code are configured in advance, L1Is the length of the character sequence for the invitation code;
extracting characters corresponding to each element value of the invitation code array in the character sequence for the invitation code, and determining a character string formed by the extracted characters as the invitation code of the user.
An invitation code generating apparatus comprising:
the receiving unit is used for receiving an invitation code generation request of a user;
the generating unit is used for generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generating request;
a processing unit, configured to perform, according to the global unique identifier id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, scaling assignment, bitwise diffusion, and bitwise confusion based on the length of the character sequence used for the invitation code on the invitation code array, so that the value of an element in the invitation code array falls into a value range [0, L1-1]Wherein, basic data information corresponding to the length of the invitation code to be generated and the character sequence for the invitation code are configured in advance, L1Is the length of the character sequence for the invitation code;
and the extracting unit is used for extracting the character corresponding to each element value of the invitation code array in the character sequence for the invitation code and determining a character string formed by the extracted characters as the invitation code of the user.
An electronic device, comprising: a processor and a memory;
the memory storing one or more computer programs executable by the processor; the processor, when executing the one or more computer programs, implements the steps in the invitation code generation method described above.
A non-transitory computer readable storage medium storing instructions which, when executed by a processor, cause the processor to implement the steps in the invitation code generation method as described above.
According to the technical scheme, after an invitation code generation request of a user is received, an invitation code array is generated according to the length of the invitation code to be generated carried by the invitation code generation request; and performing reduction-multiplication assignment, bitwise diffusion and bitwise confusion operation based on the character sequence length for the invitation code configured in advance on the invitation code array according to the global unique identifier id carried by the invitation code generation request and the basic data information configured aiming at the length of the invitation code to be generated in advance, so that characters for the invitation code configured in advance are uniformly distributed, and the invitation code obtained by extracting the character corresponding to the value of each element of the invitation code array in the character sequence for the invitation code is not repeated. It can be seen that the invention does not need to query the database and generate the primary key of the database in advance, and also supports the invitation code generation mechanism with the specified length, thus improving the generation efficiency of the invitation code, reducing the generation complexity of the invitation code and controlling the length of the generated invitation code under the condition of ensuring that the invitation code is not repeated.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1 is a flowchart of an invite code generation method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a second invite code generation method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a method for generating a three-invite code according to an embodiment of the present invention;
FIG. 4 is a flowchart of a method for generating a four-invite code according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of an invitation code generating apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a flowchart of an invite code generation method according to an embodiment of the present invention, and as shown in fig. 1, the method mainly includes the following steps:
step 101, receiving an invitation code generation request of a user;
102, generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generation request;
103, according to the global unique identifier id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, carrying out scaling assignment, bitwise diffusion and bitwise confusion on the invitation code array based on the length of the character sequence used for the invitation code so as to enable the value of the element in the invitation code array to fall into a value range [0, L ]1-1]Wherein, basic data information corresponding to the length of the invitation code to be generated and the character sequence for the invitation code are all configured in advance, L1Is the length of the character sequence for the invitation code;
and 104, extracting characters corresponding to each element value of the invitation code array in the character sequence for the invitation code, and determining a character string formed by the extracted characters as the invitation code of the user.
As can be seen from the method shown in fig. 1, in the embodiment, in the process of generating the invitation code, according to the global unique identifier id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, the abbreviated assignment, the bitwise diffusion and the bitwise confusion operation based on the pre-configured length of the character sequence used for the invitation code are performed on the invitation code array, so that the pre-configured characters used for the invitation code are uniformly distributed, and the invitation code obtained by extracting the character corresponding to the value of each element of the invitation code array in the character sequence used for the invitation code is not repeated. The invention does not need to inquire the database and pre-generate the main key of the database, and supports the invitation code generation mechanism with the specified length, thereby improving the generation efficiency of the invitation code, reducing the generation complexity of the invitation code and controlling the length of the generated invitation code under the condition of ensuring that the invitation code is not repeated.
Referring to fig. 2, fig. 2 is a flowchart of a method for generating a second invite code according to an embodiment of the present invention, and as shown in fig. 2, the method mainly includes the following steps:
step 201, receiving an invitation code generation request of a user;
in this embodiment, the invitation code generation request carries information such as the length of the invitation code to be generated and a global unique identifier (id).
Step 202, generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generation request;
in this embodiment, the length of the invitation code array is the same as the length of the invitation code to be generated.
In this embodiment, configuring corresponding basic data information in advance for the length of the invitation code to be generated specifically includes: first basic data which is relatively prime to the length of the character sequence used for the invitation code, second basic data which is relatively prime to the length of the invitation code to be generated, and random data; wherein the character sequence for the invitation code is preconfigured.
Step 2031, calculating the product of the id carried by the invitation code generation request and the first basic data corresponding to the length of the invitation code to be generated, and adding the product and the random data corresponding to the length of the invitation code to be generated to obtain an initial value;
step 2032, according to the initial value, according to the assignment sequence corresponding to the length of the invitation code to be generated, performing the scaling assignment and bitwise diffusion based on the character sequence length of the invitation code on the invitation code array;
in this embodiment, a corresponding assignment sequence is configured in advance for the length of the invitation code to be generated.
In this embodiment, the invitation code array is subjected to the scaling assignment and bitwise diffusion based on the character sequence length for the invitation code according to the assignment sequence corresponding to the length of the invitation code to be generated, so that the value of an element in the invitation code array can fall into a value range [0, L [, L ]1-1]And because the initial value is obtained by multiplying the id by the first basic data with the character sequence length of the invitation code being relatively prime and then adding the result to random data, when the scaling assignment and bitwise diffusion based on the character sequence length of the invitation code are carried out, the characters for the invitation code can be uniformly distributed in an invitation code array.
Step 2033, performing bit-wise confusion on the invitation code array by using the second basic data corresponding to the length of the invitation code to be generated.
In this embodiment, bit-wise obfuscating the invitation code array may disturb elements in the invitation code array, thereby further increasing the difficulty of decoding the invitation code.
The above steps 2031 to 2033 are specific refinements of step 103 shown in fig. 1.
And 204, extracting characters corresponding to each element value of the invitation code array in the character sequence for the invitation code, and determining a character string formed by the extracted characters as the invitation code of the user.
As can be seen from the method shown in fig. 2, in this embodiment, when the invitation code is generated, the group of invitation codes is scaled down, assigned and bit-diffused according to the globally unique identifier id carried by the request for generating the invitation code, and the first basic data and the random data corresponding to the length of the invitation code to be generated, so that the characters for the invitation code configured in advance are uniformly distributed, and then the group of invitation codes is bit-wise confused by using the second basic data corresponding to the length of the invitation code to be generated, so as to increase the difficulty in decoding the invitation code extracted subsequently. The invention does not need to inquire the database and pre-generate the main key of the database, and supports the invitation code generation mechanism with the specified length, thereby improving the generation efficiency of the invitation code, reducing the generation complexity of the invitation code and controlling the length of the generated invitation code under the condition of ensuring that the invitation code is not repeated.
Referring to fig. 3, fig. 3 is a flowchart of a method for generating a three-invite code according to an embodiment of the present invention, and as shown in fig. 3, the method mainly includes the following steps:
step 301, receiving an invitation code generation request of a user;
step 302, generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generation request;
in this embodiment, the invitation code generation request carries information such as the length of the invitation code to be generated and a global unique identifier (id).
In this embodiment, configuring corresponding basic data information in advance for the length of the invitation code to be generated specifically includes: first basic data which is relatively prime to the length of the character sequence used for the invitation code, second basic data which is relatively prime to the length of the invitation code to be generated, and random data; wherein the character sequence for the invitation code is preconfigured. In addition, a corresponding assignment sequence is configured for the length of the invitation code to be generated in advance.
In this embodiment, the length of the random data corresponding to the length of the invitation code to be generated may be consistent with the length of the invitation code to be generated, so that the numerical range of the modulo calculation result is larger in the subsequent diffusion process of the elements in the invitation code array.
Step 3031, calculating the product of the id carried by the invitation code generation request and the first basic data corresponding to the length of the invitation code to be generated, and adding the product and the random data corresponding to the length of the invitation code to be generated to obtain an initial value;
3032a, according to the initial value, according to the length of the invitation code to be generated (the length of the invitation code to be generated is marked as L)2) Corresponding assignment sequence to the first L of the invitation code array2-1 element is assigned a reduction based on the length of the character sequence used for the invitation code;
in this embodiment, the assignment sequence corresponding to the length of the invitation code to be generated may be: top L of the invitation code array2-1 array number ordering order. Here, the length of the invitation code to be generated is L2The length of the invitation code array is also L2For only the top L of the invitation code array2-1 element is subjected to scaling assignment, and the last element of the invitation code array is used as an interference item and assigned by other methods.
In this embodiment, according to the initial value, the first L of the invitation code array is subjected to assignment in the order corresponding to the length of the invitation code to be generated2-1 element performs a scaling assignment based on the length of the character sequence for the invitation code, specifically comprising:
s11, setting the element of the invitation code array corresponding to the 1 st array sequence number in the sorting sequence as the initial value;
s12, setting the element of the invitation code array corresponding to the ith number group sequence number in the sorting sequence as the element value of the invitation code array corresponding to the ith-1 number group sequence number in the sorting sequence and the character sequence length L for the invitation code1Where i is 2, … …, L2-1。
Assuming that the length of the invitation code to be generated is 5, the length of the invitation code Array is also 5, and according to the reduction assignment method provided in the above steps S11-S12, the specific process of performing reduction assignment on the first 4 elements of the invitation code Array is as follows: assigning the initial value to Array [0]]Mixing Array [0]]And L1Assigning the quotient value of (1) to Array]Will Array [1]]And L1Assigning the quotient value of (2)]Will Array [2]]And L1Assigning the quotient value of (2) to Array [3]]。
Step 3032b, utilizing the initial value and the user invitationThe length of the character sequence of the invitation code, and the top L of the invitation code array2-1 element to do a bitwise diffusion based on the length of the character sequence for the invitation code;
in this embodiment, the first L to the invitation code array is executed in step 3032a2After assignment of 1 element, further bitwise diffusion based on the length of the character sequence for the invitation code is performed on these elements in step 3032 b.
In this embodiment, the first L of the invitation code array is adjusted by using the initial value and the length of the character sequence for the invitation code2-1 element for bitwise spreading based on the length of the character sequence for invitation code, comprising:
top L for the invitation code array2-each element of 1 element, calculating a product of the array number corresponding to the element and the initial value, calculating an addition result of the element value and the product, determining a modulo calculation result of the addition result on the length of the character sequence for the invite code, and updating the element value to the modulo calculation result.
Here, through the first L of the invitation code array2-1 element to perform the above diffusion operation, the first L of the invitation code array may be made2All values of-1 element fall within the interval [0, L1-1]。
Step 3032c, according to the front L in the invitation code array2-1 element determining an interference value, calculating the product of the interference value and the first basic data corresponding to the length of the invitation code to be generated, determining the modulo calculation result of the product on the length of the character sequence for the invitation code, and setting the sequence number of the array in the invitation code array to be L2The element value of-1 is set as the modulo calculation result.
In this embodiment, the first L in the invitation code array is determined2-1 element determining an interference value, comprising in particular:
calculating the Lth in the invitation code array21-m element to the L2-an addition result of element values of 1 element, which is determined as the interference value, wherein m is a preset valueInteger value, and m is in the interval [2, L2-1]In (1). Here, L2Is an integer greater than 2.
As can be seen, in this embodiment, the last element of the invitation code array (i.e., Lth2Element) without participating in its preceding L2-1 element reduction assignment operation, but according to its top L2-1 element determines an interference value, calculates the product of the interference value and the first basic data corresponding to the length of the invitation code to be generated, and assigns the product to the element according to the result of the modulo calculation of the length of the character sequence used for the invitation code, thereby further increasing the difficulty of deciphering the finally generated invitation code.
The above steps 3032a to 3032c are specific refinements of step 2032 shown in fig. 2.
And 3033, performing bit-wise confusion on the invitation code array by using second basic data corresponding to the length of the invitation code to be generated.
In this embodiment, bit-wise obfuscating the invitation code array may disturb elements in the invitation code array, thereby further increasing the difficulty of decoding the invitation code.
The above steps 3031 to 3033 are specific refinements of the step 103 shown in fig. 1.
And 304, extracting characters corresponding to each element value of the invitation code array in the character sequence for the invitation code, and determining a character string formed by the extracted characters as the invitation code of the user.
As can be seen from the method shown in fig. 3, in this embodiment, when the invitation code is generated, the global unique identifier id carried in the request for generating the invitation code, and the first base data corresponding to the length of the invitation code to be generated are used to determine the first L of the invitation code array2-1 element is subjected to scaling assignment and bitwise diffusion, and the last element of the invitation code array is assigned by other methods, so that on one hand, characters for invitation codes configured in advance are uniformly distributed, and on the other hand, the difficulty in deciphering the invitation codes extracted subsequently is increased; then, the second basic data corresponding to the length of the invitation code to be generated is utilized to generate the invitation codeThe array is subjected to bit-wise confusion, so that the decoding difficulty of the invitation codes obtained by subsequent extraction is further increased. The invention does not need to inquire the database and pre-generate the main key of the database, and supports the invitation code generation mechanism with the specified length, thereby improving the generation efficiency of the invitation code, reducing the generation complexity of the invitation code and controlling the length of the generated invitation code under the condition of ensuring that the invitation code is not repeated.
Referring to fig. 4, fig. 4 is a flowchart of a method for generating a four-invite code according to an embodiment of the present invention, and as shown in fig. 4, the method mainly includes the following steps:
step 401, receiving an invitation code generation request of a user;
step 402, generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generation request;
in this embodiment, the invitation code generation request carries information such as the length of the invitation code to be generated and a global unique identifier (id).
In this embodiment, configuring corresponding basic data information in advance for the length of the invitation code to be generated specifically includes: first basic data which is relatively prime to the length of the character sequence used for the invitation code, second basic data which is relatively prime to the length of the invitation code to be generated, and random data; wherein the character sequence for the invitation code is preconfigured. In addition, a corresponding assignment sequence is configured for the length of the invitation code to be generated in advance.
In this embodiment, the character sequence for the invitation code may be any group of characters input by the user through the electronic device, specifically set by the user, and may be, for example, 10 numeric characters: 0-9 and 26 english letters: A-Z selects a plurality of characters as characters for the invitation code, and arranges the characters into a character sequence according to any sequence, wherein the specific arrangement sequence can be set by a user, and the invention is not limited.
Step 4031, calculate the product of id carried by the invitation code generation request and the first basic data corresponding to the length of the invitation code to be generated, add the product and the random data corresponding to the length of the invitation code to be generated to obtain an initial value;
step 4032, according to the initial value, performing reduced-multiple assignment and bitwise diffusion based on the character sequence length for the invitation code on the invitation code array according to an assignment sequence corresponding to the length of the invitation code to be generated;
in this embodiment, the invitation code array is subjected to the scaling assignment and bitwise diffusion based on the character sequence length for the invitation code according to the assignment sequence corresponding to the length of the invitation code to be generated, so that the value of an element in the invitation code array can fall into a value range [0, L [, L ]1-1]And because the initial value is obtained by multiplying the id by the first basic data with the character sequence length of the invitation code being relatively prime and then adding the result to random data, when the scaling assignment and bitwise diffusion based on the character sequence length of the invitation code are carried out, the characters for the invitation code can be uniformly distributed in an invitation code array.
Step 4033a, aiming at each element in the invitation code array, determining a new array serial number corresponding to the element according to the array serial number corresponding to the element and second basic data corresponding to the length of the invitation code to be generated;
in this embodiment, determining the new array sequence number corresponding to the element according to the array sequence number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated specifically includes:
and calculating the product of the array serial number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated, determining the modulo calculation result of the product on the length of the invitation code to be generated, and determining the modulo calculation result as the new array serial number corresponding to the element.
Step 4033b, according to the new array sequence number corresponding to each element in the invitation code array, position adjustment is performed on the elements in the invitation code array.
In this embodiment, it is assumed that the character sequence for the invitation code is as follows: ' H ', ' V ', ' E ', '8', ' S ', '2', ' D ', ' Z ', ' X ', '9', ' C ', '7', ' P ', '1', '5', ' I ', ' K ', '3', ' M ', ' J ', ' U ', ' F ', ' R ', '4', ' W ', ' Y ', ' L ', ' T ', ' N ', '6', ' B ', ' G ', ' Q ', then L ' can be known as L1=35。
Assuming that the length of the invitation code to be generated is 5, and in step 4043a, it is determined that the values of the 1 st element to the 5 th element of the invitation code array are sequentially: array [0] ═ 1, Array [1] ═ 5, Array [2] ═ 7, Array [3] ═ 4, Array [4] 8; and it is determined in step 4043b that the new sequence numbers of the 1 st to 5 th elements are 0, 1, 3, 2, and 4 in sequence, it is determined that, in the invite code Array after position adjustment, Array [0] is 1, Array [1] is 5, Array [2] is 4, Array [3] is 7, and Array [4] is 8.
Steps 4033a through 4033b above are a detailed refinement of step 2033 shown in fig. 2.
The above steps 4031 to 4033b are specific refinements of step 103 shown in fig. 1.
Step 404, extracting a character corresponding to each element value of the invitation code array in the character sequence for the invitation code, and determining a character string formed by the extracted characters as the invitation code of the user.
In this embodiment, the characters corresponding to each element value of the invitation code array in the character sequence for the invitation code may be extracted, for example, in the invitation code array obtained after step 4043b is executed, the extracted characters are sequentially as follows:
array [0] ═ 1, corresponding to 'V' in the sequence of characters used for the invite code;
array [1] ═ 5, corresponding to '2' in the sequence of characters used for the invite code;
array [2] ═ 4, corresponding to 'S' in the sequence of characters used for the invite code;
array [3] ═ 7, corresponding to 'Z' in the sequence of characters used for the invite code;
array [4] ═ 8, corresponding to 'X' in the sequence of characters used for the invite code.
The invitation code of the user is thus available as V2 SZX.
As can be seen from the method shown in fig. 4, in this embodiment, when the invitation code is generated, the global unique identifier id carried by the invitation code generation request, and the first basic data and the random data corresponding to the length of the invitation code to be generated perform scaling assignment and bitwise diffusion on the invitation code array, so that the characters for the invitation code configured in advance are uniformly distributed, and then the second basic data corresponding to the length of the invitation code to be generated is used to perform bitwise confusion on the invitation code array, so as to disturb the element positions in the invitation code array, thereby increasing the difficulty in decoding the invitation code extracted subsequently. The invention does not need to inquire the database and pre-generate the main key of the database, and supports the invitation code generation mechanism with the specified length, thereby improving the generation efficiency of the invitation code, reducing the generation complexity of the invitation code and controlling the length of the generated invitation code under the condition of ensuring that the invitation code is not repeated.
An embodiment of the present invention further provides an invitation code generating device, as shown in fig. 5, where the invitation code generating device includes:
a receiving unit 501, configured to receive an invitation code generation request of a user;
a generating unit 502, configured to generate an invitation code array according to the length of the invitation code to be generated carried in the invitation code generation request;
a processing unit 503, configured to perform, according to the globally unique identifier id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, scaling assignment, bitwise diffusion, and bitwise confusion based on the length of the character sequence used for the invitation code on the invitation code array, so that the value of an element in the invitation code array falls into a value range [0, L1-1]Wherein, basic data information corresponding to the length of the invitation code to be generated and the character sequence for the invitation code are configured in advance, L1Is the length of the character sequence for the invitation code;
an extracting unit 504, configured to extract a character corresponding to each element value of the invitation code array in the character sequence for the invitation code, and determine a character string formed by the extracted characters as the invitation code of the user.
In the device shown in figure 5 of the drawings,
the basic data information corresponding to the length of the invitation code to be generated comprises: the first basic data which is relatively prime to the length of the character sequence used for the invitation code, the second basic data which is relatively prime to the length of the invitation code to be generated, and random data;
the processing unit 503, according to the id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, performs scaling assignment, bitwise diffusion, and bitwise confusion based on the length of the character sequence used for the invitation code on the invitation code array, and includes:
calculating the product of the id and first basic data corresponding to the length of the invitation code to be generated, and adding the product and random data corresponding to the length of the invitation code to be generated to obtain an initial value;
according to the initial value, carrying out scaling assignment and bitwise diffusion on the invitation code array based on the character sequence length of the invitation code according to the assignment sequence corresponding to the length of the invitation code to be generated; wherein, the assignment sequence corresponding to the length of the invitation code to be generated is configured in advance;
and performing bit-wise confusion on the invitation code array by utilizing second basic data corresponding to the length of the invitation code to be generated.
In the device shown in figure 5 of the drawings,
the assignment sequence corresponding to the length of the invitation code to be generated is the front L of the invitation code array2-1 array number ordering order; wherein L is2Is the length of the invitation code to be generated;
the processing unit 503, according to the initial value, performs, according to an assignment sequence corresponding to a length of an invitation code to be generated, a scaling assignment and bitwise diffusion based on the length of the character sequence used for the invitation code on the invitation code array, and includes:
according to the initial value, the first L of the invitation code array is subjected to assignment sequence corresponding to the length of the invitation code to be generated2-1 element is assigned a reduction based on the length of the character sequence used for the invitation code;
using the initial value and the character sequence length for the invitation code, and applying the first L of the invitation code array2-1 element to do a bitwise diffusion based on the length of the character sequence for the invitation code;
according to the front L in the invitation code array2-1 element determining an interference value, calculating the interference value and the value to be generatedThe product of the first basic data corresponding to the length of the invitation code, determining the modulo calculation result of the product on the length of the character sequence for the invitation code, and setting the serial number of the array in the invitation code array as L2The element value of-1 is set as the modulo calculation result.
In the device shown in figure 5 of the drawings,
the processing unit 503, according to the initial value, performs processing on the first L of the invitation code array according to the assignment sequence corresponding to the length of the invitation code to be generated2-1 element for a reduced-scale assignment based on the length of the character sequence for invitation codes, comprising:
setting an element in the invitation code array corresponding to the 1 st array sequence number in the sorting sequence as the initial value;
setting the element of the invitation code array corresponding to the ith number group sequence number in the sorting sequence as the element value of the invitation code array corresponding to the ith-1 number group sequence number in the sorting sequence and the character sequence length L for the invitation code1Where i is 2, … …, L2-1。
In the device shown in figure 5 of the drawings,
the processing unit 503 uses the initial value and the length of the character sequence for the invitation code to perform the first L of the invitation code array2-1 element for bitwise spreading based on the length of the character sequence for invitation code, comprising:
top L for the invitation code array2-each element of 1 element, calculating a product of the array number corresponding to the element and the initial value, calculating an addition result of the element value and the product, determining a modulo calculation result of the addition result on the length of the character sequence for the invite code, and updating the element value to the modulo calculation result.
In the device shown in figure 5 of the drawings,
the processing unit 503 is configured to determine the top L in the invitation code array2-1 element determining an interference value comprising:
calculating the Lth in the invitation code array21-m element to the L2-an addition result of the element values of 1 element, which addition result is determined as said interference value, wherein m is a predetermined integer value and m is located in the interval [2, L2-1]In (1).
In the device shown in figure 5 of the drawings,
the processing unit 503 performs bit-wise obfuscation on the invitation code array by using second basic data corresponding to the length of the invitation code to be generated, and includes:
aiming at each element in the invitation code array, determining a new array serial number corresponding to the element according to the array serial number corresponding to the element and second basic data corresponding to the length of the invitation code to be generated;
and adjusting the positions of the elements in the invitation code array according to the new array serial number corresponding to each element in the invitation code array.
In the device shown in figure 5 of the drawings,
the determining, by the processing unit 503, a new array sequence number corresponding to the element according to the array sequence number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated includes:
and calculating the product of the array serial number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated, determining the modulo calculation result of the product on the length of the invitation code to be generated, and determining the modulo calculation result as the new array serial number corresponding to the element.
An embodiment of the present invention further provides an electronic device, as shown in fig. 6, where the electronic device includes: a processor 601 and a memory 602;
the memory 602 storing one or more computer programs executable by the processor 601; the processor, when executing the one or more computer programs, implements the steps in the invitation code generation method as shown in any of the flowcharts of figures 1-4.
An embodiment of the present invention further provides a non-transitory computer readable storage medium storing instructions, wherein the instructions, when executed by a processor, cause the processor to implement the steps in the invitation code generation method as shown in any of the flowcharts of fig. 1-4.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (11)

1. A method for generating an invitation code, the method comprising:
receiving an invitation code generation request of a user;
generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generation request;
according to the global unique identification id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, carrying out scaling assignment, bitwise diffusion and bitwise confusion on the invitation code array based on the character sequence length used for the invitation code so as to enable the element value in the invitation code array to fall into the value range [0, L ]1-1]Wherein, basic data information corresponding to the length of the invitation code to be generated and the character sequence for the invitation code are configured in advance, L1Is the length of the character sequence for the invitation code;
extracting characters corresponding to each element value of the invitation code array in the character sequence for the invitation code, and determining a character string formed by the extracted characters as the invitation code of the user.
2. The method of claim 1,
the basic data information corresponding to the length of the invitation code to be generated comprises: the first basic data which is relatively prime to the length of the character sequence used for the invitation code, the second basic data which is relatively prime to the length of the invitation code to be generated, and random data;
according to the id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, carrying out scaling assignment, bitwise diffusion and bitwise confusion on the basis of the length of the character sequence used for the invitation code on the invitation code array, and comprising the following steps:
calculating the product of the id and first basic data corresponding to the length of the invitation code to be generated, and adding the product and random data corresponding to the length of the invitation code to be generated to obtain an initial value;
according to the initial value, carrying out scaling assignment and bitwise diffusion on the invitation code array based on the character sequence length of the invitation code according to the assignment sequence corresponding to the length of the invitation code to be generated; wherein, the assignment sequence corresponding to the length of the invitation code to be generated is configured in advance;
and performing bit-wise confusion on the invitation code array by utilizing second basic data corresponding to the length of the invitation code to be generated.
3. The method of claim 2,
the assignment sequence corresponding to the length of the invitation code to be generated is the front L of the invitation code array2-1 array number ordering order; wherein L is2Is the length of the invitation code to be generated;
according to the initial value, carrying out the scaling assignment and bitwise diffusion based on the character sequence length of the invitation code on the invitation code array according to the assignment sequence corresponding to the length of the invitation code to be generated, comprising the following steps:
according to the initial value, the first L of the invitation code array is subjected to assignment sequence corresponding to the length of the invitation code to be generated2-1 element is assigned a reduction based on the length of the character sequence used for the invitation code;
using the initial value and the character sequence length for the invitation code, and applying the first L of the invitation code array2-1 element to do a bitwise diffusion based on the length of the character sequence for the invitation code;
according to the front L in the invitation code array2-1 element determining an interference value, calculating the product of the interference value and the first basic data corresponding to the length of the invitation code to be generated, determining the modulo calculation result of the product on the length of the character sequence for the invitation code, and setting the sequence number of the array in the invitation code array to be L2The element value of-1 is set as the modulo calculation result.
4. The method of claim 3,
according to the initial value, the first L of the invitation code array is subjected to assignment sequence corresponding to the length of the invitation code to be generated2-1 element for a reduced-scale assignment based on the length of the character sequence for invitation codes, comprising:
setting an element in the invitation code array corresponding to the 1 st array sequence number in the sorting sequence as the initial value;
setting the element of the invitation code array corresponding to the ith number group sequence number in the sorting sequence as the element value of the invitation code array corresponding to the ith-1 number group sequence number in the sorting sequence and the character sequence length L for the invitation code1Where i is 2, … …, L2-1。
5. The method of claim 3,
using the initial value and the character sequence length for the invitation code, and applying the first L of the invitation code array2-1 element for bitwise spreading based on the length of the character sequence for invitation code, comprising:
top L for the invitation code array2-each element of 1 element, calculating a product of the array number corresponding to the element and the initial value, calculating an addition result of the element value and the product, determining a modulo calculation result of the addition result on the length of the character sequence for the invite code, and updating the element value to the modulo calculation result.
6. The method of claim 3,
according to the front L in the invitation code array2-1 element determining an interference value comprising:
calculating the Lth in the invitation code array21-m element to the L2-the result of addition of element values of 1 element, the result of this addition beingDetermining the value as the interference value, wherein m is a preset integer value and m is located in the interval [2, L2-1]In (1).
7. The method of claim 2,
performing bitwise confusion on the invitation code array by using second basic data corresponding to the length of the invitation code to be generated, wherein the bitwise confusion comprises the following steps:
aiming at each element in the invitation code array, determining a new array serial number corresponding to the element according to the array serial number corresponding to the element and second basic data corresponding to the length of the invitation code to be generated;
and adjusting the positions of the elements in the invitation code array according to the new array serial number corresponding to each element in the invitation code array.
8. The method of claim 7,
determining a new array sequence number corresponding to the element according to the array sequence number corresponding to the element and second basic data corresponding to the length of the invitation code to be generated, including:
and calculating the product of the array serial number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated, determining the modulo calculation result of the product on the length of the invitation code to be generated, and determining the modulo calculation result as the new array serial number corresponding to the element.
9. An invitation code generating apparatus, comprising:
the receiving unit is used for receiving an invitation code generation request of a user;
the generating unit is used for generating an invitation code array according to the length of the invitation code to be generated carried by the invitation code generating request;
a processing unit, configured to perform, according to the global unique identifier id carried by the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, scaling assignment, bitwise diffusion, and bitwise confusion based on the length of the character sequence used for the invitation code on the invitation code arraySo as to make the value of the element in the invitation code array fall into the value range [0, L1-1]Wherein, basic data information corresponding to the length of the invitation code to be generated and the character sequence for the invitation code are configured in advance, L1Is the length of the character sequence for the invitation code;
and the extracting unit is used for extracting the character corresponding to each element value of the invitation code array in the character sequence for the invitation code and determining a character string formed by the extracted characters as the invitation code of the user.
10. An electronic device, comprising: a processor and a memory;
the memory storing one or more computer programs executable by the processor; the processor, when executing the one or more computer programs, implements the steps in the invitation code generation method of any of claims 1-8.
11. A non-transitory computer readable storage medium storing instructions which, when executed by a processor, cause the processor to implement the steps in the invitation code generation method of any of claims 1-8.
CN202110255960.2A 2021-03-09 2021-03-09 Invitation code generation method and device, electronic equipment and storage medium Pending CN113824807A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110255960.2A CN113824807A (en) 2021-03-09 2021-03-09 Invitation code generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110255960.2A CN113824807A (en) 2021-03-09 2021-03-09 Invitation code generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113824807A true CN113824807A (en) 2021-12-21

Family

ID=78912403

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110255960.2A Pending CN113824807A (en) 2021-03-09 2021-03-09 Invitation code generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113824807A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090110197A1 (en) * 2007-10-30 2009-04-30 Harris Corporation Cryptographic system configured for extending a repetition period of a random sequence
WO2012140144A1 (en) * 2011-04-12 2012-10-18 Telefonica, S.A. Method and system for improving the synchronization of stream ciphers
CN109977371A (en) * 2019-03-21 2019-07-05 江苏工程职业技术学院 A kind of generation method of character type garbage classification code
CN110619204A (en) * 2019-08-28 2019-12-27 深圳市融壹买信息科技有限公司 Invitation code generation method and device, terminal equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090110197A1 (en) * 2007-10-30 2009-04-30 Harris Corporation Cryptographic system configured for extending a repetition period of a random sequence
WO2012140144A1 (en) * 2011-04-12 2012-10-18 Telefonica, S.A. Method and system for improving the synchronization of stream ciphers
CN109977371A (en) * 2019-03-21 2019-07-05 江苏工程职业技术学院 A kind of generation method of character type garbage classification code
CN110619204A (en) * 2019-08-28 2019-12-27 深圳市融壹买信息科技有限公司 Invitation code generation method and device, terminal equipment and storage medium

Similar Documents

Publication Publication Date Title
US8595273B2 (en) Hash algorithm using randomization function
CA2522046A1 (en) Methods and apparatus for secure and adaptive delivery of multimedia content
CN114285575B (en) Image encryption and decryption method and device, storage medium and electronic device
CN112487253B (en) User invitation code generation method, verification method, device, equipment and storage medium
CN110166238A (en) The generation method and device of quantum key
WO2010011715A2 (en) Keyboard display posing an identification challenge for an automated agent
CN104112096A (en) Multi-point touch method and device
CN113824807A (en) Invitation code generation method and device, electronic equipment and storage medium
CN110234082B (en) Addressing method and device of mobile terminal, storage medium and server
CN115242450B (en) Password data input method, device and storage medium
CN108512657B (en) Password generation method and device
CN108667647B (en) Method and device for setting device parameters and server
Putra et al. Steganography for data hiding in digital audio data using combined least significant bit and 4-wrap length method
CN114500035B (en) Data encryption system based on service data sharing cloud platform
Sivakumar et al. Generation of random key stream using word grid puzzle for the applications of cryptography
CN115409020A (en) Chinese character grouping test method and system based on word balance and computer readable storage medium
CN109634560B (en) Random number generation method, device and storage medium
CN113901437A (en) Password generation method and device, computer equipment and storage medium
CN113935051A (en) Lightweight text rapid encryption and decryption method
CN112417326A (en) URL conversion method and device, electronic equipment and storage medium
CN114499465A (en) Hash algorithm, circuit and electronic equipment
JP6144438B1 (en) Information processing apparatus, information processing system, information processing method, and computer program
KR20160066318A (en) Apparatus and method for generating a random nuber using a prefer image
US10572654B2 (en) Method for a repeatable creation of a random file
CN112865971B (en) Private key generation method and device, electronic equipment and computer readable storage medium

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