Invitation code generation method, device, electronic device and storage medium

By using global unique identification id and basic data information to perform character sequence operation when generating invitation codes, the problems of low efficiency and high complexity in the prior art are solved, and efficient and easy-to-use invitation code generation of specified lengths is achieved.

CN113824807BActive Publication Date: 2025-01-03BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110255960.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-09
Publication Date
2025-01-03
Estimated Expiration
2041-03-09

AI Technical Summary

Technical Problem

When generating non-repetitive and practical invitation codes, the prior art is inefficient and complex, and the length of the generated invitation code is not suitable for use, especially when the number of primary keys is insufficient when the user is explosively growing.

Method used

By receiving the user's invitation code generation request, an invitation code array is generated, and the global unique identification id and the basic data information of the length of the invitation code to be generated is used to double the character sequence length, bitwise diffusion and bitwise obfuscation, to ensure invitation The code array element generates a unique invitation code of the specified length within the interval [0, L1-1].

Benefits of technology

Improves the efficiency of invitation code generation, reduces complexity, and supports invitation code generation of specified lengths, ensuring that the generated invitation code is not duplicated and easy to use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113824807B_ABST
    Figure CN113824807B_ABST
Patent Text Reader

Abstract

The present invention provides an invitation code generation method, device, electronic device and storage medium, the method comprising: receiving an invitation code generation request from 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; performing multiple assignment, bitwise diffusion and bitwise obfuscation on the invitation code array based on the length of a character sequence used for the invitation code according to a global unique identifier carried by the invitation code generation request and basic data information corresponding to the length of the invitation code to be generated, so that the element values ​​in the invitation code array fall into a value interval [0, L1-1], wherein the basic data information corresponding to the length of the invitation code to be generated and the character sequence used for the invitation code are pre-configured, and L1 is the length of the character sequence used for the invitation code; extracting characters corresponding to the values ​​of each element of the invitation code array in the character sequence used for the invitation code, and determining a character string composed of the extracted characters as the invitation code of the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to an invitation code generation method, device, electronic device and storage medium. Background Art

[0002] There are currently several ways to generate unique and unguessable invitation codes:

[0003] 1. Each time an invitation code is generated, the database is checked to determine whether it is a duplicate. If it is a duplicate, a new invitation code needs to be generated. This method is extremely inefficient.

[0004] Second, use the primary key of the database as the unique key, and perform shuffle or insertion operations. For example, if the primary key is 8000001, generate N random numbers or letters (set as required) after taking it out, and insert it into the primary key value to form a string such as 8000E0V0S1D, so as to ensure that the invitation code is not repeated. This method requires pre-generating a large number of primary keys at one time, which increases the complexity and has the problem of insufficient number of primary keys after the explosive growth of users.

[0005] 3. Use algorithms to ensure the uniqueness of invitation codes. For example, the invitation codes are generated using the UUID algorithm, SHA algorithm, RC4 algorithm, etc. However, the invitation codes generated using the UUID and SHA algorithms are too long and not practical; and the invitation codes generated using the RC4 algorithm contain symbols that are not letters and numbers, which are not suitable for use as user invitation codes, and are also too long and not practical. Summary of the invention

[0006] In view of this, an object of the present invention is to provide an invitation code generation method, device, electronic device and storage medium, which can improve the efficiency of invitation code generation, reduce complexity, and control the length of the generated invitation code.

[0007] In order to achieve the above object, the present invention provides the following technical solutions:

[0008] A method for generating an invitation code, comprising:

[0009] Receive the user's invitation code generation request;

[0010] Generate an invitation code array according to the length of the invitation code to be generated carried in the invitation code generation request;

[0011] 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, the invitation code array is subjected to multiple assignment based on the length of the character sequence used for the invitation code, bitwise diffusion, and bitwise obfuscation, so that the element values ​​in the invitation code array fall within the value interval [0, L1-1], wherein the basic data information corresponding to the length of the invitation code to be generated and the character sequence used for the invitation code are pre-configured, and L1 is the length of the character sequence used for the invitation code;

[0012] The characters corresponding to the values ​​of each element of the invitation code array are extracted from the character sequence used for the invitation code, and a character string consisting of the extracted characters is determined as the invitation code of the user.

[0013] An invitation code generating device, comprising:

[0014] A receiving unit, used to receive a user's invitation code generation request;

[0015] A generating unit, 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;

[0016] A processing unit, configured to perform, based on the globally unique identifier id carried in the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, multiple assignment, bitwise diffusion, and bitwise obfuscation on the invitation code array based on the length of the character sequence used for the invitation code, so that the element values ​​in the invitation code array fall within the value interval [0, L1-1], wherein the basic data information corresponding to the length of the invitation code to be generated and the character sequence used for the invitation code are pre-configured, and L1 is the length of the character sequence used for the invitation code;

[0017] The extraction unit is used to extract the characters corresponding to the values ​​of each element of the invitation code array in the character sequence used for the invitation code, and determine the character string composed of the extracted characters as the user's invitation code.

[0018] An electronic device, comprising: a processor and a memory;

[0019] The memory stores one or more computer programs that can be executed by the processor; when the processor executes the one or more computer programs, the steps in the above-mentioned invitation code generation method are implemented.

[0020] A non-transitory computer-readable storage medium stores instructions, which, when executed by a processor, enable the processor to implement the steps in the above-mentioned invitation code generation method.

[0021] It can be seen from the above technical scheme that in the present invention, after receiving the invitation code generation request from the user, an invitation code array is generated according to the length of the invitation code to be generated carried by the invitation code generation request; according to the globally unique identifier id carried by the invitation code generation request, and the basic data information pre-configured for the length of the invitation code to be generated, the invitation code array is subjected to the reduction assignment, bitwise diffusion, and bitwise confusion operations based on the pre-configured length of the character sequence for the invitation code, so that the pre-configured characters for the invitation code are evenly distributed, and then the invitation code obtained by extracting the characters corresponding to the values ​​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 present invention does not need to query the database and pre-generate the database primary key, and also supports the invitation code generation mechanism of the specified length, so that the invitation code generation efficiency can be improved, the complexity of the invitation code generation can be reduced, and the length of the generated invitation code can be controlled while ensuring that the invitation code is not repeated. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0023] Figure 1 is a flow chart of a method for generating an invitation code according to a first embodiment of the present invention;

[0024] Figure 2 This is a flow chart of a method for generating an invitation code according to Embodiment 2 of the present invention;

[0025] Figure 3 This is a flow chart of a method for generating an invitation code according to Embodiment 3 of the present invention;

[0026] Figure 4 is a flow chart of a method for generating an invitation code according to a fourth embodiment of the present invention;

[0027] Figure 5 It is a structural diagram of an invitation code generating device according to an embodiment of the present invention;

[0028] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0029] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0030] See also Figure 1 , Figure 1 is a flow chart of a method for generating an invitation code according to an embodiment of the present invention. Figure 1 As shown, the method mainly includes the following steps:

[0031] Step 101: Receive a user's invitation code generation request;

[0032] Step 102: Generate an invitation code array according to the length of the invitation code to be generated carried in the invitation code generation request;

[0033] Step 103: 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, the invitation code array is subjected to multiple assignment based on the length of the character sequence used for the invitation code, bitwise diffusion, and bitwise obfuscation, so that the element values ​​in the invitation code array fall within the value interval [0, L1-1], wherein the basic data information corresponding to the length of the invitation code to be generated and the character sequence used for the invitation code are both pre-configured, and L1 is the length of the character sequence used for the invitation code;

[0034] Step 104: extract the characters corresponding to the values ​​of each element of the invitation code array in the character sequence used for the invitation code, and determine the character string composed of the extracted characters as the invitation code of the user.

[0035] according to Figure 1 It can be seen from the method shown that in this embodiment, in the process of generating the invitation code, 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, the invitation code array is subjected to the reduction assignment, bitwise diffusion, and bitwise confusion operations based on the length of the pre-configured character sequence for the invitation code, so that the pre-configured characters for the invitation code are evenly distributed, and the invitation code obtained by extracting the characters corresponding to the values ​​of each element of the invitation code array in the character sequence for the invitation code is not repeated. The present invention does not need to query the database and pre-generate the database primary key, and also supports the invitation code generation mechanism of the specified length, so that the invitation code generation efficiency can be improved, the complexity of the invitation code generation can be reduced, and the length of the generated invitation code can be controlled while ensuring that the invitation code is not repeated.

[0036] See also Figure 2 , Figure 2 is a flow chart of a method for generating an invitation code according to Embodiment 2 of the present invention. Figure 2 As shown, the method mainly includes the following steps:

[0037] Step 201: Receive a user's invitation code generation request;

[0038] In this embodiment, the invitation code generation request carries information such as the length of the invitation code to be generated and a globally unique identifier (ID).

[0039] Step 202: Generate an invitation code array according to the length of the invitation code to be generated carried in the invitation code generation request;

[0040] In this embodiment, the length of the invitation code array is the same as the length of the invitation code to be generated.

[0041] In this embodiment, corresponding basic data information is pre-configured for the length of the invitation code to be generated, specifically including: first basic data that is coprime with the length of the character sequence used for the invitation code, second basic data that is coprime with the length of the invitation code to be generated, and random data; wherein, the character sequence used for the invitation code is pre-configured.

[0042] Step 2031: Calculate the product of the ID carried in the invitation code generation request and the first basic data corresponding to the length of the invitation code to be generated, and add the product to the random data corresponding to the length of the invitation code to be generated to obtain an initial value;

[0043] Step 2032: According to the initial value, the invitation code array is assigned a multiple of the length of the character sequence used for the invitation code and is bit-wise diffused in accordance with the assignment order corresponding to the length of the invitation code to be generated;

[0044] In this embodiment, a corresponding assignment sequence is pre-configured for the length of the invitation code to be generated.

[0045] In this embodiment, the invitation code array is assigned a multiple of the length of the character sequence used for the invitation code and is diffused bit by bit according to the assignment order corresponding to the length of the invitation code to be generated, so that the element values ​​in the invitation code array can fall into the value interval [0, L1-1]. Since the initial value is obtained by multiplying the id and the first basic data that is coprime to the length of the character sequence used for the invitation code and then adding the random data, when the multiple of the length of the character sequence used for the invitation code is assigned and diffused bit by bit, the characters used for the invitation code can be evenly distributed in the invitation code array.

[0046] Step 2033: using the second basic data corresponding to the length of the invitation code to be generated, perform bitwise obfuscation on the invitation code array.

[0047] In this embodiment, the invitation code array is bit-wise obfuscated, so that the elements in the invitation code array can be disrupted, thereby further increasing the difficulty of deciphering the invitation code.

[0048] The above steps 2031 to 2033 are Figure 1 The specific refinement of step 103 is shown.

[0049] Step 204: extract the characters corresponding to the values ​​of each element of the invitation code array in the character sequence used for the invitation code, and determine the character string composed of the extracted characters as the invitation code of the user.

[0050] according to Figure 2 It can be seen from the method shown that in this embodiment, when generating an invitation code, the invitation code array is doubled and bitwise diffused according to the globally unique identifier id carried by the invitation code generation request, and the first basic data and random data corresponding to the length of the invitation code to be generated, so that the pre-configured characters for the invitation code are evenly distributed, and then the invitation code array is bitwise obfuscated using the second basic data corresponding to the length of the invitation code to be generated, so as to increase the difficulty of deciphering the invitation code extracted later. The present invention does not require querying the database and pre-generating the database primary key, and also supports the invitation code generation mechanism of a specified length, so that the invitation code generation efficiency can be improved, the complexity of the invitation code generation can be reduced, and the length of the generated invitation code can be controlled while ensuring that the invitation code is not repeated.

[0051] See also Figure 3 , Figure 3 is a flow chart of a method for generating an invitation code according to Embodiment 3 of the present invention. Figure 3 As shown, the method mainly includes the following steps:

[0052] Step 301: Receive a user's invitation code generation request;

[0053] Step 302: Generate an invitation code array according to the length of the invitation code to be generated carried in the invitation code generation request;

[0054] In this embodiment, the invitation code generation request carries information such as the length of the invitation code to be generated and a globally unique identifier (ID).

[0055] In this embodiment, corresponding basic data information is pre-configured for the length of the invitation code to be generated, specifically including: first basic data that is co-prime with the length of the character sequence used for the invitation code, second basic data that is co-prime with the length of the invitation code to be generated, and random data; wherein the character sequence used for the invitation code is pre-configured. In addition, a corresponding assignment order is also pre-configured for the length of the invitation code to be generated.

[0056] In this embodiment, the length of the random data corresponding to the length of the invitation code to be generated can be consistent with the length of the invitation code to be generated, so that the numerical range of the modulo calculation result can be larger in the subsequent diffusion process of the elements in the invitation code array.

[0057] Step 3031: Calculate the product of the ID carried in the invitation code generation request and the first basic data corresponding to the length of the invitation code to be generated, and add the product to the random data corresponding to the length of the invitation code to be generated to obtain an initial value;

[0058] Step 3032a: According to the initial value, the first L2-1 elements of the invitation code array are assigned values ​​based on the length of the character sequence used for the invitation code in a value assignment order corresponding to the length of the invitation code to be generated (the length of the invitation code to be generated is denoted as L2);

[0059] In this embodiment, the value assignment order corresponding to the length of the invitation code to be generated may be: the sorting order of the first L2-1 array numbers of the invitation code array. Here, the length of the invitation code to be generated is L2, and the length of the invitation code array is also L2. Only the first L2-1 elements of the invitation code array are assigned with multiples, and the last element of the invitation code array is used as a interference item and assigned with other methods.

[0060] In this embodiment, according to the initial value, the first L2-1 elements of the invitation code array are assigned values ​​based on the length of the character sequence for the invitation code in the order of assignment corresponding to the length of the invitation code to be generated, which specifically includes:

[0061] S11, setting the element in the invitation code array corresponding to the first array number in the sorting order as the initial value;

[0062] S12. Set the element in the invitation code array corresponding to the i-th array number in the sorting order to the quotient of the element value in the invitation code array corresponding to the i-1-th array number in the sorting order and the length L1 of the character sequence for the invitation code, where i=2, ..., L2-1.

[0063] Assuming that the length of the invitation code to be generated is 5, the length of the invitation code array Array is also 5. According to the reduction assignment method given in the above steps S11-S12, the specific process of reducing the first 4 elements of the invitation code array Array is as follows: assign the initial value to Array[0], assign the quotient of Array[0] and L1 to Array[1], assign the quotient of Array[1] and L1 to Array[2], and assign the quotient of Array[2] and L1 to Array[3].

[0064] Step 3032b: using the initial value and the length of the character sequence for the invitation code, perform bitwise diffusion based on the length of the character sequence for the invitation code on the first L2-1 elements of the invitation code array;

[0065] In this embodiment, after the first L2-1 elements of the invitation code array are assigned values ​​in step 3032a, these elements are further subjected to bitwise diffusion based on the length of the character sequence for the invitation code in step 3032b.

[0066] In this embodiment, the initial value and the length of the character sequence used for the invitation code are used to perform bitwise diffusion based on the length of the character sequence used for the invitation code on the first L2-1 elements of the invitation code array, including:

[0067] For each element in the first L2-1 elements of the invitation code array, calculate the product of the array serial number corresponding to the element and the initial value, calculate the addition result of the element value and the product, determine the modulo calculation result of the addition result on the length of the character sequence used for the invitation code, and update the element value to the modulo calculation result.

[0068] Here, by performing the above diffusion operation on the first L2-1 elements of the invitation code array, the values ​​of the first L2-1 elements of the invitation code array can all fall into the interval [0, L1-1].

[0069] Step 3032c, determine an interference value based on the first L2-1 elements in the invitation code array, calculate the product of the interference value and the first basic data corresponding to the length of the invitation code to be generated, determine the modulo calculation result of the product on the length of the character sequence used for the invitation code, and set the element value with array number L2-1 in the invitation code array to the modulo calculation result.

[0070] In this embodiment, an interference value is determined according to the first L2-1 elements in the invitation code array, specifically including:

[0071] The sum of the element values ​​from the L2-1-mth element to the L2-1th element in the invitation code array is calculated, and the sum is determined as the interference value, where m is a preset integer value and m is in the interval [2, L2-1]. Here, L2 is an integer greater than 2.

[0072] It can be seen that in this embodiment, the last element of the invitation code array (i.e., the L2th element) does not participate in the doubling operation of the first L2-1 elements, but determines an interference value based on the first L2-1 elements, 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 result of the modulo calculation of the length of the character sequence used for the invitation code to the element, thereby further increasing the difficulty of deciphering the invitation code finally generated.

[0073] The above steps 3032a to 3032c are Figure 2 The specific refinement of step 2032 is shown.

[0074] Step 3033: Use the second basic data corresponding to the length of the invitation code to be generated to perform bitwise obfuscation on the invitation code array.

[0075] In this embodiment, the invitation code array is bit-wise obfuscated, so that the elements in the invitation code array can be disrupted, thereby further increasing the difficulty of deciphering the invitation code.

[0076] The above steps 3031 to 3033 are Figure 1 The specific refinement of step 103 is shown.

[0077] Step 304: extract the characters corresponding to the values ​​of each element of the invitation code array in the character sequence used for the invitation code, and determine the character string composed of the extracted characters as the user's invitation code.

[0078] according to Figure 3 It can be seen from the method shown that in this embodiment, when generating an invitation code, the first L2-1 elements of the invitation code array are assigned by multiples and bitwise diffusion according to the globally unique identifier id carried by the invitation code generation request, and the first basic data and random data corresponding to the length of the invitation code to be generated, and the last element of the invitation code array is assigned by other methods, which, on the one hand, allows the pre-configured characters for the invitation code to be evenly distributed, and on the other hand, increases the difficulty of deciphering the invitation code extracted subsequently; then, the invitation code array is bitwise obfuscated using the second basic data corresponding to the length of the invitation code to be generated, thereby further increasing the difficulty of deciphering the invitation code extracted subsequently. The present invention does not require querying a database and pre-generating a database primary key, and also supports a mechanism for generating invitation codes of a specified length, thereby being able to improve the efficiency of invitation code generation, reduce the complexity of invitation code generation, and control the length of the generated invitation code while ensuring that the invitation code is not repeated.

[0079] See also Figure 4 , Figure 4 is a flow chart of a method for generating an invitation code according to a fourth embodiment of the present invention. Figure 4As shown, the method mainly includes the following steps:

[0080] Step 401: Receive a user's invitation code generation request;

[0081] Step 402: Generate an invitation code array according to the length of the invitation code to be generated carried in the invitation code generation request;

[0082] In this embodiment, the invitation code generation request carries information such as the length of the invitation code to be generated and a globally unique identifier (ID).

[0083] In this embodiment, corresponding basic data information is pre-configured for the length of the invitation code to be generated, specifically including: first basic data that is co-prime with the length of the character sequence used for the invitation code, second basic data that is co-prime with the length of the invitation code to be generated, and random data; wherein the character sequence used for the invitation code is pre-configured. In addition, a corresponding assignment order is also pre-configured for the length of the invitation code to be generated.

[0084] In this embodiment, the character sequence used for the invitation code can be any group of characters input by the user through an electronic device, which is specifically set by the user. For example, multiple characters can be selected from 10 numeric characters: 0-9 and 26 English letters: AZ as characters for the invitation code, and arranged in any order to form a character sequence. The specific arrangement order can be set by the user, and the present invention is not limited to this.

[0085] Step 4031: Calculate the product of the ID carried in the invitation code generation request and the first basic data corresponding to the length of the invitation code to be generated, and add the product to the random data corresponding to the length of the invitation code to be generated to obtain an initial value;

[0086] Step 4032: According to the initial value, the invitation code array is assigned a multiple of the length of the character sequence used for the invitation code and is bit-wise diffused in accordance with the assignment order corresponding to the length of the invitation code to be generated;

[0087] In this embodiment, the invitation code array is assigned a multiple of the length of the character sequence used for the invitation code and is diffused bit by bit according to the assignment order corresponding to the length of the invitation code to be generated, so that the element values ​​in the invitation code array can fall into the value interval [0, L1-1]. Since the initial value is obtained by multiplying the id and the first basic data that is coprime to the length of the character sequence used for the invitation code and then adding the random data, when the multiple of the length of the character sequence used for the invitation code is assigned and diffused bit by bit, the characters used for the invitation code can be evenly distributed in the invitation code array.

[0088] Step 4033a: for each element in the invitation code array, determine a new array number corresponding to the element according to the array number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated;

[0089] 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:

[0090] Calculate the product of the array number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated, determine the modulo calculation result of the product on the length of the invitation code to be generated, and determine the modulo calculation result as the new array number corresponding to the element.

[0091] Step 4033b: adjust the position of the elements in the invitation code array according to the new array sequence number corresponding to each element in the invitation code array.

[0092] In this embodiment, assuming that the character sequence used 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', it can be seen that L1=35.

[0093] Assume that the length of the invitation code to be generated is 5, and in step 4043a, it is determined that the values ​​of the 1st to 5th elements of the invitation code array are: Array[0]=1, Array[1]=5, Array[2]=7, Array[3]=4, Array[4]8; and in step 4043b, it is determined that the new serial numbers of the 1st to 5th elements are 0, 1, 3, 2, 4, respectively. Then, it can be determined that in the invitation code array after the position adjustment, Array[0]=1, Array[1]=5, Array[2]=4, Array[3]=7, Array[4]=8.

[0094] The above steps 4033a to 4033b are Figure 2 The specific refinement of step 2033 is shown.

[0095] The above steps 4031 to 4033b are Figure 1 The specific refinement of step 103 is shown.

[0096] Step 404: extract the characters corresponding to the values ​​of each element of the invitation code array from the character sequence used for the invitation code, and determine the character string composed of the extracted characters as the invitation code of the user.

[0097] In this embodiment, the characters corresponding to the values ​​of each element of the invitation code array in the character sequence used for the invitation code can be extracted. For example, in the invitation code array obtained after executing step 4043b, the characters extracted are as follows:

[0098] Array[0]=1, corresponding to 'V' in the character sequence used for the invitation code;

[0099] Array[1]=5, corresponding to '2' in the character sequence used for the invitation code;

[0100] Array[2]=4, corresponding to 'S' in the character sequence for the invitation code;

[0101] Array[3]=7, corresponding to 'Z' in the character sequence used for the invitation code;

[0102] Array[4]=8, corresponding to 'X' in the character sequence used for the invitation code.

[0103] Therefore, the user's invitation code is V2SZX.

[0104] according to Figure 4 It can be seen from the method shown that in this embodiment, when generating an invitation code, the invitation code array is doubled and bitwise diffused according to the globally unique identifier id carried by the invitation code generation request, and the first basic data and random data corresponding to the length of the invitation code to be generated, so that the pre-configured characters for the invitation code are evenly distributed, and then the invitation code array is bitwise obfuscated using the second basic data corresponding to the length of the invitation code to be generated, so as to disrupt the position of the elements in the invitation code array, thereby increasing the difficulty of deciphering the invitation code extracted later. The present invention does not require querying the database and pre-generating the database primary key, and also supports the invitation code generation mechanism of a specified length, so that the invitation code generation efficiency can be improved, the complexity of the invitation code generation can be reduced, and the length of the generated invitation code can be controlled while ensuring that the invitation code is not repeated.

[0105] The embodiment of the present invention also provides an invitation code generating device, such as Figure 5 As shown, the invitation code generating device includes:

[0106] Receiving unit 501, used to receive a user's invitation code generation request;

[0107] 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;

[0108] The processing unit 503 is used to perform a multiple assignment, bitwise diffusion, and bitwise obfuscation on the invitation code array based on the length of the character sequence used for the invitation code 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, so that the element values ​​in the invitation code array fall within the value interval [0, L1-1], wherein the basic data information corresponding to the length of the invitation code to be generated and the character sequence used for the invitation code are pre-configured, and L1 is the length of the character sequence used for the invitation code;

[0109] The extraction unit 504 is used to extract the characters corresponding to the values ​​of each element of the invitation code array in the character sequence used for the invitation code, and determine the character string composed of the extracted characters as the invitation code of the user.

[0110] Figure 5 In the device shown,

[0111] The basic data information corresponding to the length of the invitation code to be generated includes: first basic data that is coprime with the length of the character sequence used for the invitation code, second basic data that is coprime with the length of the invitation code to be generated, and random data;

[0112] The processing unit 503 performs, according to the ID carried in the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, a reduction assignment based on the length of the character sequence used for the invitation code, bitwise diffusion, and bitwise obfuscation on the invitation code array, including:

[0113] Calculate the product of the id and the first basic data corresponding to the length of the invitation code to be generated, and add the product to the random data corresponding to the length of the invitation code to be generated to obtain an initial value;

[0114] According to the initial value, the invitation code array is assigned a multiple of the length of the character sequence for the invitation code and is bit-wise diffused according to the assignment order corresponding to the length of the invitation code to be generated; wherein the assignment order corresponding to the length of the invitation code to be generated is pre-configured;

[0115] The invitation code array is bit-wise obfuscated using the second basic data corresponding to the length of the invitation code to be generated.

[0116] Figure 5 In the device shown,

[0117] The value assignment order corresponding to the length of the invitation code to be generated is the sorting order of the first L2-1 array numbers of the invitation code array; wherein L2 is the length of the invitation code to be generated;

[0118] The processing unit 503, according to the initial value, performs a multiple assignment and a bitwise diffusion on the invitation code array based on the length of the character sequence for the invitation code in accordance with the assignment order corresponding to the length of the invitation code to be generated, including:

[0119] According to the initial value, assigning values ​​to the first L2-1 elements of the invitation code array in a value assignment order corresponding to the length of the invitation code to be generated, based on the multiple of the length of the character sequence used for the invitation code;

[0120] Using the initial value and the length of the character sequence for the invitation code, performing bitwise diffusion based on the length of the character sequence for the invitation code on the first L2-1 elements of the invitation code array;

[0121] An interference value is determined based on the first L2-1 elements in the invitation code array, the product of the interference value and the first basic data corresponding to the length of the invitation code to be generated is calculated, the modulo calculation result of the product on the length of the character sequence used for the invitation code is determined, and the element value with array number L2-1 in the invitation code array is set to the modulo calculation result.

[0122] Figure 5 In the device shown,

[0123] The processing unit 503, according to the initial value, assigns a multiple of the length of the character sequence used for the invitation code to the first L2-1 elements of the invitation code array in a value assignment order corresponding to the length of the invitation code to be generated, including:

[0124] Setting the element in the invitation code array corresponding to the first array number in the sorting order to the initial value;

[0125] The element in the invitation code array corresponding to the i-th array number in the sorting order is set to the quotient of the element value in the invitation code array corresponding to the i-1-th array number in the sorting order and the length L1 of the character sequence used for the invitation code, where i=2, ..., L2-1.

[0126] Figure 5 In the device shown,

[0127] The processing unit 503 performs bitwise diffusion based on the length of the character sequence for the invitation code on the first L2-1 elements of the invitation code array using the initial value and the length of the character sequence for the invitation code, including:

[0128] For each element in the first L2-1 elements of the invitation code array, calculate the product of the array serial number corresponding to the element and the initial value, calculate the addition result of the element value and the product, determine the modulo calculation result of the addition result on the length of the character sequence used for the invitation code, and update the element value to the modulo calculation result.

[0129] Figure 5 In the device shown,

[0130] The processing unit 503 determines an interference value according to the first L2-1 elements in the invitation code array, including:

[0131] The sum of the element values ​​from the L2-1-mth element to the L2-1th element in the invitation code array is calculated, and the sum is determined as the interference value, where m is a preset integer value and is in the interval [2, L2-1].

[0132] Figure 5 In the device shown,

[0133] The processing unit 503 performs bitwise obfuscation on the invitation code array using the second basic data corresponding to the length of the invitation code to be generated, including:

[0134] For each element in the invitation code array, determine 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;

[0135] According to the new array sequence number corresponding to each element in the invitation code array, the position of the elements in the invitation code array is adjusted.

[0136] Figure 5 In the device shown,

[0137] The processing unit 503 determines 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, including:

[0138] Calculate the product of the array number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated, determine the modulo calculation result of the product on the length of the invitation code to be generated, and determine the modulo calculation result as the new array number corresponding to the element.

[0139] The embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, the electronic device includes: a processor 601 and a memory 602;

[0140] The memory 602 stores one or more computer programs that can be executed by the processor 601; when the processor executes the one or more computer programs, the following is achieved: Figure 1-4 The steps in the invitation code generation method shown in any flowchart.

[0141] The embodiment of the present invention further provides a non-transient computer-readable storage medium, wherein the non-transient computer-readable storage medium stores instructions, wherein when the instructions are executed by a processor, the processor implements the following Figure 1-4 The steps in the invitation code generation method shown in any flowchart.

[0142] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for generating an invitation code, characterized in that: The method includes: Receive the user's invitation code generation request; Generate an invitation code array according to the length of the invitation code to be generated carried in the invitation code generation request; 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, the invitation code array is subjected to multiple assignment based on the length of the character sequence used for the invitation code, bitwise diffusion, and bitwise obfuscation, so that the element values ​​in the invitation code array fall within the value interval [0, L1-1], wherein the basic data information corresponding to the length of the invitation code to be generated and the character sequence used for the invitation code are pre-configured, and L1 is the length of the character sequence used for the invitation code; Extracting characters corresponding to the values ​​of each element of the invitation code array from the character sequence used for the invitation code, and determining a character string consisting of the extracted characters as the invitation code of the user; The assignment of the reduction value includes: setting the element corresponding to the first array number in the sorting order in the invitation code array to the initial value; setting the element corresponding to the i-th array number in the sorting order in the invitation code array to the quotient of the element value corresponding to the i-1-th array number in the sorting order in the invitation code array and the character sequence length L1 for the invitation code, wherein i=2, ..., L2-1; The bitwise diffusion includes: for each element of the first L2-1 elements of the invitation code array, calculating the product of the array serial number corresponding to the element and the initial value, calculating the addition result of the element value and the product, determining the modulo calculation result of the addition result on the length of the character sequence used for the invitation code, and updating the element value to the modulo calculation result.

2. The method according to claim 1, characterized in that The basic data information corresponding to the length of the invitation code to be generated includes: first basic data that is coprime with the length of the character sequence used for the invitation code, second basic data that is coprime with 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, the invitation code array is subjected to a multiple assignment based on the length of the character sequence used for the invitation code, bitwise diffusion, and bitwise obfuscation, including: Calculate the product of the id and the first basic data corresponding to the length of the invitation code to be generated, and add the product to the random data corresponding to the length of the invitation code to be generated to obtain an initial value; According to the initial value, the invitation code array is assigned a multiple of the length of the character sequence for the invitation code and is bit-wise diffused according to the assignment order corresponding to the length of the invitation code to be generated; wherein the assignment order corresponding to the length of the invitation code to be generated is pre-configured; The invitation code array is bit-wise obfuscated using the second basic data corresponding to the length of the invitation code to be generated.

3. The method according to claim 2, characterized in that The order of assignment corresponding to the length of the invitation code to be generated is the sorting order of the first L2-1 array numbers of the invitation code array; wherein L2 is the length of the invitation code to be generated; According to the initial value, the invitation code array is assigned a multiple of the length of the character sequence for the invitation code and is bit-wise diffused according to the assignment order corresponding to the length of the invitation code to be generated, including: According to the initial value, assigning values ​​to the first L2-1 elements of the invitation code array in a value assignment order corresponding to the length of the invitation code to be generated, based on the multiple of the length of the character sequence used for the invitation code; Using the initial value and the length of the character sequence for the invitation code, performing bitwise diffusion based on the length of the character sequence for the invitation code on the first L2-1 elements of the invitation code array; An interference value is determined based on the first L2-1 elements in the invitation code array, the product of the interference value and the first basic data corresponding to the length of the invitation code to be generated is calculated, the modulo calculation result of the product on the length of the character sequence used for the invitation code is determined, and the element value with array number L2-1 in the invitation code array is set to the modulo calculation result.

4. The method according to claim 3, characterized in that Determining an interference value according to the first L2-1 elements in the invitation code array includes: The sum of the element values ​​from the L2-1-mth element to the L2-1th element in the invitation code array is calculated, and the sum is determined as the interference value, where m is a preset integer value and is in the interval [2, L2-1].

5. The method according to claim 2, characterized in that: Using the second basic data corresponding to the length of the invitation code to be generated, the invitation code array is bit-wise obfuscated, including: For each element in the invitation code array, determine 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; According to the new array sequence number corresponding to each element in the invitation code array, the position of the elements in the invitation code array is adjusted.

6. The method according to claim 5, characterized in that Determining 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: Calculate the product of the array number corresponding to the element and the second basic data corresponding to the length of the invitation code to be generated, determine the modulo calculation result of the product on the length of the invitation code to be generated, and determine the modulo calculation result as the new array number corresponding to the element.

7. An invitation code generating device, characterized in that: The device includes: A receiving unit, used to receive a user's invitation code generation request; A generating unit, 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, configured to perform, based on the globally unique identifier id carried in the invitation code generation request and the basic data information corresponding to the length of the invitation code to be generated, multiple assignment, bitwise diffusion, and bitwise obfuscation on the invitation code array based on the length of the character sequence used for the invitation code, so that the element values ​​in the invitation code array fall within the value interval [0, L1-1], wherein the basic data information corresponding to the length of the invitation code to be generated and the character sequence used for the invitation code are pre-configured, and L1 is the length of the character sequence used for the invitation code; An extraction unit, used to extract characters corresponding to the values ​​of each element of the invitation code array in the character sequence used for the invitation code, and determine the character string composed of the extracted characters as the invitation code of the user; The assignment of the reduction value includes: setting the element corresponding to the first array number in the sorting order in the invitation code array to the initial value; setting the element corresponding to the i-th array number in the sorting order in the invitation code array to the quotient of the element value corresponding to the i-1-th array number in the sorting order in the invitation code array and the character sequence length L1 for the invitation code, wherein i=2, ..., L2-1; The bitwise diffusion includes: for each element of the first L2-1 elements of the invitation code array, calculating the product of the array serial number corresponding to the element and the initial value, calculating the addition result of the element value and the product, determining the modulo calculation result of the addition result on the length of the character sequence used for the invitation code, and updating the element value to the modulo calculation result.

8. An electronic device, characterized in that: The electronic device includes: a processor and a memory; The memory stores one or more computer programs that can be executed by the processor; when the processor executes the one or more computer programs, the steps in the invitation code generation method as described in any one of claims 1 to 6 are implemented.

9. A non-transitory computer-readable storage medium storing instructions, characterized in that: When the instructions are executed by a processor, the processor implements the steps in the invitation code generation method as described in any one of claims 1 to 6.