Method and device for generating identification

By introducing random number grouping and switching mechanisms into the initial identification generated by the snowflake algorithm, the problem of low identification security in the prior art is solved, and more efficient identification generation security is achieved.

CN114048229BActive Publication Date: 2024-12-20CCB FINTECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111317528.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-09
Publication Date
2024-12-20
Estimated Expiration
2041-11-09

AI Technical Summary

Technical Problem

The identifiers generated by the snowflake algorithm in the prior art are orderly, resulting in low security and easy to be cracked, which in turn affects the access security of data.

Method used

By introducing random number grouping and exchange mechanisms into the initial identifier generated by the snowflake algorithm, the target identifier is generated to ensure the irregularity of the identifier and thus improve its security. The specific steps include: generating initial identification based on user instructions, determining random numbers, grouping and exchanging corresponding sub-identification locations, ensuring that the final generated identification is irregular.

Benefits of technology

It effectively improves the generated identification security, reduces the risk of being cracked, and ensures the uniqueness and irreversibility of the identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114048229B_ABST
    Figure CN114048229B_ABST
Patent Text Reader

Abstract

This invention provides an identifier generation method and apparatus. The method includes: responding to an identifier generation command sent by a user; generating an initial identifier corresponding to a target object based on a snowflake algorithm, wherein the target object is obtained through the identifier generation command; determining a random number corresponding to the initial identifier; grouping the initial identifier into groups, using the random number as the number of sub-identifiers in each group of the initial identifier, to obtain each first group of the initial identifier; determining the position of a target group within each first group using the random number and the number of groups in each first group; and swapping the sub-identifiers with the same target group position between any two specified first groups to obtain the target identifier of the target object. This ensures that the generated identifier is random, improving the security of the generated identifier.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] In complex systems, such as those of financial and e-commerce products, it is often necessary to uniquely identify large amounts of data, messages, and accounts, and to generate globally unique and monotonically increasing identifiers. Identifiers cannot be repeated or rolled back under any circumstances, and the system must be able to generate identifiers efficiently.

[0003] In the prior art, the snowflake algorithm is used to generate identifiers. Because the identifiers generated by the snowflake algorithm are orderly, the efficiency of database indexing can be improved. However, due to the orderliness of the identifiers generated by the snowflake algorithm, the identifiers can be cracked by exhaustive means, and the cracked identifiers can be used to access data and obtain the data corresponding to the identifiers. As a result, the security of the identifiers is relatively low. Summary of the invention

[0004] In an exemplary embodiment of the present invention, a method and apparatus for generating an identifier are provided to improve the security of the generated identifier.

[0005] A first aspect of the present invention provides a method for generating an identifier, the method comprising:

[0006] In response to an identifier generation instruction sent by a user, generating an initial identifier corresponding to a target object based on a snowflake algorithm, wherein the target object is obtained by the identifier generation instruction;

[0007] determining a random number corresponding to the initial identifier; and,

[0008] The initial identifier is grouped by using the random number as the number of sub-identifiers in each group of the initial identifier to obtain each first group of the initial identifier;

[0009] Determine the target group position in each first group by using the random number and the group number of the first group;

[0010] For any two designated first groups, the sub-identifiers of the target group with the same position are exchanged respectively to obtain the target identifier of the target object.

[0011] In this embodiment, in response to the identification generation instruction sent by the user, an initial identification corresponding to the target object is generated based on the snowflake algorithm, wherein the target object is obtained through the identification generation instruction; a random number corresponding to the initial identification is determined; and the initial identification is grouped using the random number as the number of sub-identifiers in each group of the initial identification to obtain each first group of the initial identification; then the target group position in each first group is determined using the random number and the number of groups of the first group; for any two designated first groups, the sub-identifiers with the same target group position are exchanged respectively to obtain the target identification of the target object. Thus, it is ensured that the generated identification is irregular, and the security of the generated identification is improved.

[0012] In one embodiment, the determining the target group position in each first group by using the random number and the group number of the first groups includes:

[0013] If the number of groups of the first grouping is an odd number and the random number is an even number, positions with even-numbered position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position;

[0014] If the number of groups of the first grouping is an odd number and the random number is an odd number, positions with odd position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position;

[0015] If the number of groups of the first groups is an even number and the random number is an even number, a position with an even-numbered position index in each first group is determined as a target group position;

[0016] If the number of groups of the first groups is an even number and the random number is an odd number, the position with an odd position index in each first group is determined as the target group position.

[0017] This embodiment determines the position of the target group in each first group by the number of first groups and the parity of the random number, thereby ensuring that the generated target identifier presents a certain randomness and reducing the risk of being cracked.

[0018] In one embodiment, the initial identifier is represented using a first specified base;

[0019] After generating the initial identifier corresponding to the target object based on the snowflake algorithm and before determining the random number corresponding to the initial identifier, the method further includes:

[0020] The initial identifiers are grouped using the length of the initial identifier and the target length to obtain second groups;

[0021] For any second group, the sub-identifiers in the second group are converted into the second specified base by using the preset conversion relationship between the first specified base and the second specified base, so as to obtain an initial identifier with a length equal to the target length.

[0022] In this embodiment, after generating an initial identifier corresponding to the target object based on the snowflake algorithm and before determining the random number corresponding to the initial identifier, the initial identifier needs to be converted into a base 2-based system to obtain an initial identifier of a target length. Since the length of the identifier generated by the snowflake algorithm is fixed, in this embodiment, the target length of the identifier can be customized according to user needs, thereby further improving the security of the generated target identifier.

[0023] In one embodiment, the using the length of the initial identifier and the target length to group the initial identifier to obtain each second group includes:

[0024] Based on the target length, determining the number of packets;

[0025] Dividing the length of the initial identifier by the target length to obtain a quotient and a remainder;

[0026] If the remainder is the first specified value, the initial identifiers are grouped using the quotient as the number of sub-identifiers in each second group to obtain each second group.

[0027] This embodiment determines the number of groups based on the target length; divides the length of the initial identifier by the target length to obtain a quotient and a remainder; if the remainder is a first specified value, the quotient is used as the number of sub-identifiers in each second group to group the initial identifier to obtain each second group. Thus, the initial identifiers are grouped according to the target length and the length of the initial identifier, and there is no need to reference other data, thereby saving calculation complexity.

[0028] In one embodiment, the method further comprises:

[0029] If the remainder is not the first specified value, initially grouping the initial identifiers according to the remainder to obtain a first initial group and a second initial group;

[0030] The initial identifiers in the first initial group are grouped by using the quotient as the number of sub-identifiers in each group in the first initial group, and the initial identifiers in the second initial group are grouped by adding the quotient to a second specified value as the number of sub-identifiers in each group in the second initial group, to obtain the second groups.

[0031] In this embodiment, if the remainder is not the first specified value, the initial identifiers are initially grouped according to the remainder to obtain a first initial group and a second initial group; the initial identifiers in the first initial group are grouped using the quotient value as the number of sub-identifiers in each group in the first initial group, and the initial identifiers in the second initial group are grouped using the quotient value plus the second specified value as the number of sub-identifiers in each group in the second initial group to obtain the second groups, thereby improving the grouping accuracy.

[0032] In one embodiment, the target length is determined by:

[0033] In response to the length input by the user, determining a specified length of the target identifier;

[0034] If it is determined that the specified length is within the set length range, obtaining the target length based on the specified length;

[0035] If it is determined that the designated length is not within the set length range, and the designated length is less than a first designated length value, determining the target length based on the first designated length value;

[0036] If it is determined that the designated length is not within the set length range, and the designated length is greater than a second designated length value, the target length is determined based on the second designated length.

[0037] This embodiment needs to determine whether the length of the identifier input by the user is within the specified range. If not, the length of the identifier needs to be processed to make the identifier length within the specified range, thereby improving the security of the identifier.

[0038] A second aspect of the present invention provides an identification generation device, the device comprising:

[0039] An initial identifier generation module, used to generate an initial identifier corresponding to a target object based on a snowflake algorithm in response to an identifier generation instruction sent by a user, wherein the target object is obtained by the identifier generation instruction;

[0040] a random number determination module, configured to determine a random number corresponding to the initial identifier; and

[0041] A first grouping module, configured to group the initial identifier by using the random number as the number of sub-identifiers in each group of the initial identifier to obtain first groups of the initial identifier;

[0042] A target group position determination module, used to determine the target group position in each first group using the random number and the number of groups of the first group;

[0043] The target identifier determination module is used to exchange the sub-identifiers with the same position in the target group for any two designated first groups, so as to obtain the target identifier of the target object.

[0044] In one embodiment, the target group location determination module is specifically used to:

[0045] If the number of groups of the first grouping is an odd number and the random number is an even number, positions with even-numbered position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position;

[0046] If the number of groups of the first grouping is an odd number and the random number is an odd number, positions with odd position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position;

[0047] If the number of groups of the first groups is an even number and the random number is an even number, a position with an even-numbered position index in each first group is determined as a target group position;

[0048] If the number of groups of the first groups is an even number and the random number is an odd number, the position with an odd position index in each first group is determined as the target group position.

[0049] In one embodiment, the initial identifier is represented using a first specified base; the apparatus further comprises:

[0050] A second grouping module is used to group the initial identifiers using the length of the initial identifier and the target length to obtain second groups after the initial identifier corresponding to the target object is generated based on the snowflake algorithm and before the random number corresponding to the initial identifier is determined;

[0051] The base conversion module is used to convert the sub-identifiers in any second group into the second specified base using the preset conversion relationship between the first specified base and the second specified base, so as to obtain an initial identifier with a length equal to the target length.

[0052] In one embodiment, the second grouping module is specifically used to:

[0053] Based on the target length, determining the number of packets;

[0054] Dividing the length of the initial identifier by the target length to obtain a quotient and a remainder;

[0055] If the remainder is the first specified value, the initial identifiers are grouped using the quotient as the number of sub-identifiers in each second group to obtain each second group.

[0056] In one embodiment, the second grouping module is further used to:

[0057] If the remainder is not the first specified value, initially grouping the initial identifiers according to the remainder to obtain a first initial group and a second initial group;

[0058] The initial identifiers in the first initial group are grouped by using the quotient as the number of sub-identifiers in each group in the first initial group, and the initial identifiers in the second initial group are grouped by adding the quotient to a second specified value as the number of sub-identifiers in each group in the second initial group, to obtain the second groups.

[0059] In one embodiment, the apparatus further comprises:

[0060] The target length determination module is used to determine the target length by:

[0061] In response to the length input by the user, determining a specified length of the target identifier;

[0062] If it is determined that the specified length is within the set length range, obtaining the target length based on the specified length;

[0063] If it is determined that the designated length is not within the set length range, and the designated length is less than a first designated length value, determining the target length based on the first designated length value;

[0064] If it is determined that the designated length is not within the set length range, and the designated length is greater than a second designated length value, the target length is determined based on the second designated length.

[0065] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, including:

[0066] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executed by the at least one processor; the instructions are executed by the at least one processor so that the at least one processor can execute the method as described in the first aspect.

[0067] According to a fourth aspect provided by an embodiment of the present invention, a computer storage medium is provided, wherein the computer storage medium stores a computer program, and the computer program is used to execute the method as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0069] Figure 1 A schematic diagram of an applicable scenario according to an embodiment of the present invention;

[0070] Figure 2 This is one of the flowcharts of a method for generating an identifier according to an embodiment of the present invention;

[0071] Figure 3 A schematic diagram of an initial identification according to an embodiment of the present invention;

[0072] Figure 4 This is a second flow chart of a method for generating an identifier according to an embodiment of the present invention;

[0073] Figure 5 This is a third flow chart of a method for generating an identifier according to an embodiment of the present invention;

[0074] Figure 6 A device for generating a mark according to an embodiment of the present invention;

[0075] Figure 7 FIG. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0076] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0077] In the embodiments of the present invention, the term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0078] The application scenarios described in the embodiments of the present invention are intended to more clearly illustrate the technical solutions of the embodiments of the present invention, and do not constitute a limitation on the technical solutions provided by the embodiments of the present invention. It is known to those skilled in the art that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present invention are also applicable to similar technical problems. In the description of the present invention, unless otherwise specified, "multiple" means two or more.

[0079] In the prior art, the snowflake algorithm is used to generate identifiers. Because the identifiers generated by the snowflake algorithm are orderly, the efficiency of database indexing can be improved. However, due to the orderliness of the identifiers generated by the snowflake algorithm, the identifiers can be cracked by exhaustive means, and the cracked identifiers can be used to access data and obtain the data corresponding to the identifiers. As a result, the security of the identifiers is relatively low.

[0080] Therefore, the present invention provides an identification generation method, which generates an initial identification corresponding to a target object based on a snowflake algorithm in response to an identification generation instruction sent by a user, wherein the target object is obtained through the identification generation instruction; determines a random number corresponding to the initial identification; and groups the initial identification using the random number as the number of sub-identifiers in each group of the initial identification to obtain each first group of the initial identification; then determines the target group position in each first group using the random number and the number of groups of the first group; and for any two specified first groups, exchanges the sub-identifiers with the same target group position respectively to obtain the target identification of the target object. Thus, it is ensured that the generated identification is irregular, and the security of the generated identification is improved. Below, the scheme of the present invention is described in detail in conjunction with the accompanying drawings.

[0081] like Figure 1 As shown, an application scenario of an identification generation method includes multiple terminal devices 110 and a server 120. Figure 1 In the example, three terminal devices 110 are used, but the number of terminal devices 110 is not limited. The terminal devices 110 may be mobile phones, tablet computers, personal computers, etc. The server 120 may be implemented by a single server or multiple servers. The server 120 may be implemented by a physical server or a virtual server.

[0082] In a possible application scenario, if user A uses terminal device 110 to send an instruction to the server to generate an identifier for a target object (message, request or account, etc.), server 120 generates an initial identifier corresponding to the target object based on the snowflake algorithm in response to the instruction sent by the user; then server 120 determines a random number corresponding to the initial identifier; and uses the random number as the number of sub-identifiers in each group of the initial identifier to group the initial identifier to obtain each first group of the initial identifier; and uses the random number and the number of groups of the first group to determine the target group position in each first group; finally, server 120 exchanges the sub-identifiers with the same target group position for any two specified first groups to obtain the target identifier of data 1. And the target identifier of the target object is sent to the terminal device 110.

[0083] like Figure 2 FIG. 1 is a flow chart of the method for generating a mark of the present invention, which may include the following steps:

[0084] Step 201: In response to an identifier generation instruction sent by a user, an initial identifier corresponding to a target object is generated based on a snowflake algorithm, wherein the target object is obtained by the identifier generation instruction;

[0085] like Figure 3 The figure shows the schematic diagram of the initial identifier generated by the snowflake algorithm. The size of the initial identifier is 64 bits. The initial identifier is divided into the following four parts:

[0086] The first part: is the first bit of the initial identifier, which is 1 bit in size. This part has no meaning. However, since the initial identifiers generated in this embodiment are all positive numbers, the value of this part is 0.

[0087] The second part: from the second to the forty-second bit of the initial identifier, with a size of 41 bits. This part indicates the timestamp in milliseconds.

[0088] The third part: from the 43rd to the 52nd bit of the initial identifier, the size is 10 bits. This part represents the working machine identifier, which means that this service can be deployed on up to 1024 machines.

[0089] The fourth part: the 53rd to 64th bits of the initial identifier, with a size of 12 bits. This part is used to record different identifiers generated in the same millisecond.

[0090] It should be noted that the identifier generation instruction includes a target object.

[0091] Step 202: Determine a random number corresponding to the initial identifier;

[0092] The random number in this embodiment has a value range of [1, 10).

[0093] Step 203: grouping the initial identifier by taking the random number as the number of sub-identifiers in each group of the initial identifier to obtain each first group of the initial identifier;

[0094] For example, if the initial identifier is 0010110000111 and the random number is 4, then the grouped initial identifier is: 0010|1100|0011|1. The first groups of the initial identifier are: 0010, 1100, 0011 and 1 respectively.

[0095] Step 204: using the random number and the number of first groups, determine the target group position in each first group;

[0096] Method 1: If the number of groups of the first grouping is an odd number and the random number is an even number, the positions with even-numbered position indexes in other first groups except the specified first grouping are determined as target group positions, and the target group position is not set for the specified first grouping.

[0097] For example, if the initial identifier is 001011000011, and the random number is 4. Then the initial identifier after grouping is: 0010|1100|0011|. The first groups of the initial identifier are: 0010, 1100, 0011. Then the number of groups (the total number of first groups) is an odd number, and the random number is an even number. Take the designated first group as the last group 0011 as an example for explanation. Then the target group positions in the first group 0010 and the first group 1100 are both the second and fourth positions. The first group 0011 does not set the target group position. And the two groups with target group positions, the sub-identifiers with the same target group position are exchanged respectively, and the target identifier obtained is: 011010000011.

[0098] Method 2: If the number of groups in the first grouping is an odd number and the random number is an odd number, positions with odd position indexes in other first groups except the specified first grouping are determined as target group positions, and the target group position is not set for the specified first grouping.

[0099] For example: if the initial identifier is 0010110000110, and the random number is 3. Then the initial identifier after grouping is: 001|011|000|011|0. The first groups of the initial identifier are: 001, 011, 000, 011 and 0 respectively. Then the number of groups (the total number of first groups) is an odd number, and the random number is an odd number. Take the example of the designated first group being the last group 0. Then the target group positions in other first groups are the first and third positions. The target group position is not set for the first group 0. And for any two adjacent first groups that have not undergone identifier exchange, the sub-identifiers with the same target group position are exchanged respectively, and the resulting target identifier is: 001011001010.

[0100] Mode three: if the number of groups of the first groups is an even number and the random number is an even number, then the position with an even-numbered position index in each first group is determined as the target group position.

[0101] For example, if the initial identifier is 0010110000110111, and the random number is 4. Then the initial identifier after grouping is: 0010|1100|0011|0111. The first groups of the initial identifier are: 0010, 1100, 0011 and 0111. Then the number of groups (the total number of first groups) is an even number, and the random number is an even number. Then the target group positions in each first group are the second and fourth positions. Then for any two adjacent first groups that have not undergone identifier exchange, the sub-identifiers with the same target group position are exchanged respectively, and the resulting target identifier is: 0110100001110011.

[0102] Mode 4: If the number of groups in the first grouping is an even number and the random number is an odd number, the position with an odd position index in each first grouping is determined as the target group position.

[0103] For example, if the initial identifier is 001011000011, and the random number is 3. Then the initial identifier after grouping is: 001|011|000|011. The first groups of the initial identifier are: 001, 011, 000 and 011 respectively. Then the number of groups (the total number of first groups) is an even number, and the random number is an odd number. Then the target group positions in each first group are the first and third positions. Then for any two adjacent first groups that have not undergone identifier exchange, the sub-identifiers with the same target group position are exchanged respectively, and the resulting target identifier is: 001011001010.

[0104] Step 205: For any two designated first groups, the sub-identifiers of the target groups having the same position are exchanged respectively to obtain the target identifier of the target object.

[0105] For example, the initial identifier is 00111111100, and the random number is 3. The initial identifier after grouping is 001|111|111|00. Then the target group positions of the first three first groups are the first and third. The target group position of the last first group is the first. If the first two first groups are the specified two first groups, and the last two first groups are the specified two first groups, the target identifier is: 10101101110.

[0106] In order to make the obtained target identification more secure, in one implementation, after executing step 201 and before executing step 202, as Figure 4 As shown, the following steps may be included:

[0107] Step 401: grouping the initial identifiers using the length of the initial identifier and the target length to obtain second groups, wherein the initial identifiers are represented using a first specified base.

[0108] In one embodiment, each second group can be obtained by:

[0109] Based on the target length, determine the number of groups; divide the length of the initial identifier by the target length to obtain a quotient and a remainder; if the remainder is a first specified value, group the initial identifier using the quotient as the number of sub-identifiers in each second group to obtain each second group.

[0110] In this embodiment, the target length is used as the number of groups for grouping, and the first specified value in this embodiment is 0.

[0111] For example, the length of the initial identifier is 64, and the initial identifier is 00000110110001101001010101001111110110010001001010111111100111 for description, and the target length is 16. Then, the number of groups is determined to be 16. And divide the length of the initial identifier by the target length, and get a quotient of 4 and a remainder of 0. Then group the initial identifier according to the number of sub-identifiers in each second group being 4, and the grouped initial identifier is 0000|0110|1100|0110|1001|0101|1010|0111|1110|1100|1000|1001|0101|1111|1110|0111, and the second groups are 0000, 0110, 0110, 0110, 1001, 0101, 1010, 0111, 1110, 1100, 1000, 1001, 0101, 1111, 1110, 0111.

[0112] In one embodiment, if the remainder is not the first specified value, the initial identifiers are initially grouped according to the remainder to obtain a first initial group and a second initial group; the initial identifiers in the first initial group are grouped using the quotient value as the number of sub-identifiers in each group in the first initial group, and the initial identifiers in the second initial group are grouped using the quotient value plus the second specified value as the number of sub-identifiers in each group in the second initial group to obtain the second groups.

[0113] The second specified value in this embodiment is 1. In this embodiment, the initial grouping of the initial identifiers by the remainder is specifically implemented as follows: the number of groups minus the remainder is multiplied by the quotient value to obtain a place value, and the first initial group is obtained based on the place value in order from left to right, and the other sub-identifiers in the initial identifier except the first initial group are used as the second initial group.

[0114] For example, the length of the initial identifier is 64, and the initial identifier is 00000110110001101001010101001111110110010001001010111111100111 for illustration, and the target length is 13. Then, the number of groups is determined to be 13. The length of the initial identifier is divided by the target length, and the quotient is 4, and the remainder is 12.

[0115] The first initial group is 0000, and the second initial group is 01101100011010010101010011111101100100010010101111111100111. Based on the above grouping rule for performing second grouping on the initial identifiers, the second groups are 0000|01101|10001|10100|10101|10100|11111|10110|01000|10010|10111|11111|00111.

[0116] Step 402: for any second group, using a preset conversion relationship between the first designated base and the second designated base, the sub-identifiers in the second group are converted into the second designated base to obtain an initial identifier with a length equal to the target length.

[0117] In this embodiment, the first designated base is binary, and the second designated base is sexagesimal.

[0118] The conversion rule between the first designated base and the second designated base is: first convert the first designated base into a decimal base, and then convert the sub-identifiers in the second group into the second designated base according to a preset correspondence between the decimal base and the second designated base.

[0119] In one embodiment, the target length is determined in the following manner, which may include the following three manners:

[0120] Method 1: In response to the length input by the user, determine the designated length of the target identifier; if it is determined that the designated length is within a set length range, obtain the target length based on the designated length.

[0121] For example, if the set length range is 12-33 and the specified length is 13, then it is determined that the specified length is within the set length range, and the target length is determined to be 13.

[0122] Method 2: In response to the length input by the user, determine the specified length of the target identifier; if it is determined that the specified length is not within the set length range and the specified length is less than a first specified length value, determine the target length based on the first specified length value.

[0123] For example, the set length range is 12-33, and the specified length is 11. It is determined that the specified length is not within the set length range, and the specified length is less than the first specified length value, and the target length is determined to be 12.

[0124] Method three: In response to the length input by the user, determine the specified length of the target identifier; if it is determined that the specified length is not within the set length range and the specified length is greater than a second specified length value, determine the target length based on the second specified length.

[0125] For example, the set length range is 12-33, and the specified length is 34. It is determined that the specified length is not within the set length range, and the specified length is greater than the first specified length value, and the target length is determined to be 33.

[0126] In order to further understand the technical solution of the present invention, Figure 5 A detailed description may include the following steps:

[0127] Step 501: In response to an identifier generation instruction sent by a user, an initial identifier corresponding to a target object is generated based on a snowflake algorithm, wherein the target object is obtained by the identifier generation instruction;

[0128] Step 502: Determine the number of packets based on a target length, wherein the target length is determined based on the identifier generation instruction;

[0129] Step 503: Divide the length of the initial identifier by the target length to obtain a quotient and a remainder;

[0130] Step 504: Determine whether the remainder is a first specified value, if so, execute step 505, if not, execute step 506;

[0131] Step 505: grouping the initial identifiers by taking the quotient value as the number of sub-identifiers in each second group to obtain each second group;

[0132] Step 506: performing initial grouping on the initial identifiers according to the remainders to obtain a first initial group and a second initial group;

[0133] Step 507: grouping the initial identifiers in the first initial group by taking the quotient as the number of sub-identifiers in each group in the first initial group, and grouping the initial identifiers in the second initial group by taking the quotient plus a second specified value as the number of sub-identifiers in each group in the second initial group, to obtain the second groups;

[0134] Step 508: for any second group, using a preset conversion relationship between the first designated base and the second designated base, convert the sub-identifier in the second group into the second designated base, and obtain an initial identifier with a length equal to the target length;

[0135] Step 509: Determine a random number corresponding to the initial identifier;

[0136] Step 510: grouping the initial identifier by using the random number as the number of sub-identifiers in each group of the initial identifier to obtain each first group of the initial identifier;

[0137] Step 511: using the random number and the number of first groups, determine the target group position in each first group;

[0138] Step 512: For any two designated first groups, the sub-identifiers of the target group with the same position are exchanged respectively to obtain the target identifier of the target object.

[0139] Based on the same inventive concept, the identification generation method described above in the present invention can also be implemented by an identification generation device. The effect of the identification generation device is similar to that of the above method, and will not be described in detail here.

[0140] Figure 6 FIG. 4 is a schematic diagram of the structure of an identification generating device according to an embodiment of the present invention.

[0141] like Figure 6 As shown, the identifier generating device 600 of the present invention may include an initial identifier generating module 610 , a random number determining module 620 , a first grouping module 630 , a target grouping position determining module 640 and a target identifier determining module 650 .

[0142] An initial identifier generation module 610, for generating an initial identifier corresponding to a target object based on a snowflake algorithm in response to an identifier generation instruction sent by a user, wherein the target object is obtained by the identifier generation instruction;

[0143] A random number determination module 620 is used to determine a random number corresponding to the initial identifier; and

[0144] A first grouping module 630, configured to group the initial identifier by using the random number as the number of sub-identifiers in each group of the initial identifier to obtain first groups of the initial identifier;

[0145] A target group position determination module 640, configured to determine the target group position in each first group using the random number and the number of groups of the first group;

[0146] The target identifier determination module 650 is used to exchange the sub-identifiers of the target groups having the same position for any two designated first groups, so as to obtain the target identifier of the target object.

[0147] In one embodiment, the target group position determination module 640 is specifically configured to:

[0148] If the number of groups of the first grouping is an odd number and the random number is an even number, positions with even-numbered position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position;

[0149] If the number of groups of the first grouping is an odd number and the random number is an odd number, positions with odd position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position;

[0150] If the number of groups of the first groups is an even number and the random number is an even number, a position with an even-numbered position index in each first group is determined as a target group position;

[0151] If the number of groups of the first groups is an even number and the random number is an odd number, the position with an odd position index in each first group is determined as the target group position.

[0152] In one embodiment, the initial identifier is represented using a first specified base; the apparatus further comprises:

[0153] A second grouping module 660 is used to group the initial identifiers using the length of the initial identifier and the target length to obtain second groups after the initial identifier corresponding to the target object is generated based on the snowflake algorithm and before the random number corresponding to the initial identifier is determined;

[0154] The base conversion module 670 is used to convert the sub-identifiers in any second group into the second specified base using the preset conversion relationship between the first specified base and the second specified base, so as to obtain an initial identifier with a length equal to the target length.

[0155] In one embodiment, the second grouping module 660 is specifically configured to:

[0156] Based on the target length, determining the number of packets;

[0157] Dividing the length of the initial identifier by the target length to obtain a quotient and a remainder;

[0158] If the remainder is the first specified value, the initial identifiers are grouped using the quotient as the number of sub-identifiers in each second group to obtain each second group.

[0159] In one embodiment, the second grouping module 660 is further configured to:

[0160] If the remainder is not the first specified value, initially grouping the initial identifiers according to the remainder to obtain a first initial group and a second initial group;

[0161] The initial identifiers in the first initial group are grouped by using the quotient as the number of sub-identifiers in each group in the first initial group, and the initial identifiers in the second initial group are grouped by adding the quotient to a second specified value as the number of sub-identifiers in each group in the second initial group, to obtain the second groups.

[0162] In one embodiment, the apparatus further comprises:

[0163] The target length determination module 680 is used to determine the target length by:

[0164] In response to the length input by the user, determining a specified length of the target identifier;

[0165] If it is determined that the specified length is within the set length range, obtaining the target length based on the specified length;

[0166] If it is determined that the designated length is not within the set length range, and the designated length is less than a first designated length value, determining the target length based on the first designated length value;

[0167] If it is determined that the designated length is not within the set length range, and the designated length is greater than a second designated length value, the target length is determined based on the second designated length.

[0168] After introducing a method and device for generating an identifier according to an exemplary embodiment of the present invention, next, an electronic device according to another exemplary embodiment of the present invention is introduced.

[0169] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".

[0170] In some possible implementations, the electronic device according to the present invention may include at least one processor and at least one computer storage medium. The computer storage medium stores program code, and when the program code is executed by the processor, the processor executes the steps of the identification generation method according to various exemplary embodiments of the present invention described above in this specification. For example, the processor may execute the following steps: Figure 2 Steps 201-205 shown in .

[0171] Refer to the following Figure 7 An electronic device 700 according to this embodiment of the present invention will be described. Figure 7 The electronic device 700 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0172] like Figure 7 As shown, the electronic device 700 is in the form of a general electronic device. The components of the electronic device 700 may include but are not limited to: at least one processor 701, at least one computer storage medium 702, and a bus 703 connecting different system components (including the computer storage medium 702 and the processor 701).

[0173] Bus 703 represents one or more of several types of bus structures, including a computer storage media bus or computer storage media controller, a peripheral bus, a processor, or a local bus using any of a variety of bus architectures.

[0174] The computer storage medium 702 may include readable media in the form of volatile computer storage media, such as random access computer storage media (RAM) 721 and / or cache storage media 722 , and may further include read-only computer storage media (ROM) 723 .

[0175] The computer storage medium 702 may also include a program / utility 725 having a set (at least one) of program modules 724, such program modules 724 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0176] The electronic device 700 may also communicate with one or more external devices 704 (e.g., keyboards, pointing devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or may communicate with any device (e.g., routers, modems, etc.) that enables the electronic device 700 to communicate with one or more other electronic devices. Such communication may be performed via an input / output (I / O) interface 705. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 706. As shown, the network adapter 706 communicates with other modules for the electronic device 700 via a bus 703. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0177] In some possible implementations, various aspects of an identifier generation method provided by the present invention may also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the identifier generation method according to various exemplary embodiments of the present invention described above in this specification.

[0178] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access computer storage medium (RAM), a read-only computer storage medium (ROM), an erasable programmable read-only computer storage medium (EPROM or flash memory), an optical fiber, a portable compact disk read-only computer storage medium (CD-ROM), an optical computer storage medium, a magnetic computer storage medium, or any suitable combination of the above.

[0179] The program product of the identification generation of the embodiment of the present invention can adopt a portable compact disk read-only computer storage medium (CD-ROM) and include program code, and can be run on an electronic device. However, the program product of the present invention is not limited to this. In this document, the readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, device or device.

[0180] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0181] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0182] Program code for performing the operation of the present invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and also conventional procedural programming languages ​​such as "C" language or similar programming languages. The program code can be executed entirely on the user electronic device, partially on the user device, as an independent software package, partially on the user electronic device and partially on the remote electronic device, or completely on the remote electronic device or server. In the case of involving a remote electronic device, the remote electronic device can be connected to the user electronic device through any type of network including a local area network (LAN) or a wide area network (WAN), or can be connected to an external electronic device (e.g., using an Internet service provider to connect through the Internet).

[0183] It should be noted that although several modules of the device are mentioned in the above detailed description, this division is only exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules described above can be embodied in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules to be embodied.

[0184] In addition, although the operations of the method of the present invention are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0185] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk computer storage media, CD-ROM, optical computer storage media, etc.) that contain computer-usable program code.

[0186] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0187] These computer program instructions may also be stored in a computer-readable computer storage medium that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable computer storage medium produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0188] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0189] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for generating an identifier, characterized in that: The method comprises: In response to an identifier generation instruction sent by a user, generating an initial identifier corresponding to a target object based on a snowflake algorithm, wherein the target object is obtained by the identifier generation instruction; determining a random number corresponding to the initial identifier; and, The initial identifier is grouped by using the random number as the number of sub-identifiers in each group of the initial identifier to obtain each first group of the initial identifier; Determine the target group position in each first group by using the random number and the group number of the first group; For any two designated first groups, the sub-identifiers in the same position of the target group are exchanged respectively to obtain the target identifier of the target object.

2. The method according to claim 1, characterized in that: The step of using the random number and the number of first groups to determine the target group position in each first group includes: If the number of groups of the first grouping is an odd number and the random number is an even number, positions with even-numbered position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position; If the number of groups of the first grouping is an odd number and the random number is an odd number, positions with odd position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position; If the number of groups of the first groups is an even number and the random number is an even number, a position with an even-numbered position index in each first group is determined as a target group position; If the number of groups of the first groups is an even number and the random number is an odd number, the position with an odd position index in each first group is determined as the target group position.

3. The method according to claim 1, characterized in that The initial identifier is represented using a first specified base; After generating the initial identifier corresponding to the target object based on the snowflake algorithm and before determining the random number corresponding to the initial identifier, the method further includes: The initial identifiers are grouped using the length of the initial identifier and the target length to obtain second groups; For any second group, the sub-identifiers in the second group are converted into the second specified base by using the preset conversion relationship between the first specified base and the second specified base, so as to obtain an initial identifier with a length equal to the target length.

4. The method according to claim 3, characterized in that The step of grouping the initial identifiers by using the length of the initial identifier and the target length to obtain second groups includes: Based on the target length, determining the number of packets; Dividing the length of the initial identifier by the target length to obtain a quotient and a remainder; If the remainder is the first specified value, the initial identifiers are grouped using the quotient as the number of sub-identifiers in each second group to obtain each second group.

5. The method according to claim 4, characterized in that The method further comprises: If the remainder is not the first specified value, initially grouping the initial identifiers according to the remainder to obtain a first initial group and a second initial group; The initial identifiers in the first initial group are grouped by using the quotient as the number of sub-identifiers in each group in the first initial group, and the initial identifiers in the second initial group are grouped by adding the quotient to a second specified value as the number of sub-identifiers in each group in the second initial group, to obtain the second groups.

6. The method according to claim 3, characterized in that The target length is determined by: In response to the length input by the user, determining a specified length of the target identifier; If it is determined that the specified length is within the set length range, obtaining the target length based on the specified length; If it is determined that the designated length is not within the set length range, and the designated length is less than a first designated length value, determining the target length based on the first designated length value; If it is determined that the designated length is not within the set length range, and the designated length is greater than a second designated length value, the target length is determined based on the second designated length.

7. A device for generating an identification, characterized in that: The device comprises: An initial identifier generation module, used to generate an initial identifier corresponding to a target object based on a snowflake algorithm in response to an identifier generation instruction sent by a user, wherein the target object is obtained by the identifier generation instruction; a random number determination module, configured to determine a random number corresponding to the initial identifier; and A first grouping module, configured to group the initial identifier by using the random number as the number of sub-identifiers in each group of the initial identifier to obtain first groups of the initial identifier; A target group position determination module, used to determine the target group position in each first group using the random number and the number of groups of the first group; The target identifier determination module is used to exchange the sub-identifiers with the same position in the target group for any two designated first groups, so as to obtain the target identifier of the target object.

8. The device according to claim 7, characterized in that The target group position determination module is specifically used to: If the number of groups of the first grouping is an odd number and the random number is an even number, positions with even-numbered position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position; If the number of groups of the first grouping is an odd number and the random number is an odd number, positions with odd position indexes in other first groups except the designated first grouping are determined as target group positions, and the designated first grouping is not set with a target group position; If the number of groups of the first groups is an even number and the random number is an even number, a position with an even-numbered position index in each first group is determined as a target group position; If the number of groups of the first groups is an even number and the random number is an odd number, the position with an odd position index in each first group is determined as the target group position.

9. The device according to claim 7, characterized in that The initial identifier is represented using a first specified base; the device further comprises: A second grouping module is used to group the initial identifiers using the length of the initial identifier and the target length to obtain second groups after the initial identifier corresponding to the target object is generated based on the snowflake algorithm and before the random number corresponding to the initial identifier is determined; The base conversion module is used to convert the sub-identifiers in any second group into the second specified base using the preset conversion relationship between the first specified base and the second specified base, so as to obtain an initial identifier with a length equal to the target length.

10. The device according to claim 9, characterized in that The second grouping module is specifically used for: Based on the target length, determining the number of packets; Dividing the length of the initial identifier by the target length to obtain a quotient and a remainder; If the remainder is the first specified value, the initial identifiers are grouped using the quotient as the number of sub-identifiers in each second group to obtain each second group.

11. The device according to claim 10, characterized in that The second grouping module is further used for: If the remainder is not the first specified value, initially grouping the initial identifiers according to the remainder to obtain a first initial group and a second initial group; The initial identifiers in the first initial group are grouped by using the quotient as the number of sub-identifiers in each group in the first initial group, and the initial identifiers in the second initial group are grouped by adding the quotient to a second specified value as the number of sub-identifiers in each group in the second initial group, to obtain the second groups.

12. The device according to claim 9, characterized in that The device also includes: The target length determination module is used to determine the target length by: In response to the length input by the user, determining a specified length of the target identifier; If it is determined that the specified length is within the set length range, obtaining the target length based on the specified length; If it is determined that the designated length is not within the set length range, and the designated length is less than a first designated length value, determining the target length based on the first designated length value; If it is determined that the designated length is not within the set length range, and the designated length is greater than a second designated length value, the target length is determined based on the second designated length.

13. An electronic device, characterized in that: It comprises at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executed by the at least one processor; and the instructions are executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1-6.

14. A computer storage medium, characterized in that: The computer storage medium stores a computer program, and the computer program is used to execute the method according to any one of claims 1-6.