Method, device, equipment and readable storage medium for generating identification

The identification sequence generated by hash encoding, randomness parameters and clock callback count values ​​solves the repetitive ID problem of the snowflake algorithm during clock callback or restart, achieving global uniqueness and data security.

CN116795782BActive Publication Date: 2025-08-26CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211001074.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-19
Publication Date
2025-08-26
Estimated Expiration
2042-08-19

AI Technical Summary

Technical Problem

In the prior art, the snowflake algorithm is prone to generate duplicate distributed IDs when clock callback or server restarts, and exposes the growth of business data, making it less secure.

Method used

The first identification sequence is determined using hash encoding and random first parameters, and a target identification is generated by combining the clock callback count value of the operating system and the irregularly increasing third identification sequence.

Benefits of technology

The generated identification sequence is globally unique, does not repeat, and the growth of business data cannot be determined, which improves the security of business data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116795782B_ABST
    Figure CN116795782B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses an identification generation method, apparatus, device and computer-readable storage medium, the method comprising: receiving an identification sequence generation request, obtaining a hash code and a first parameter in response to the identification sequence generation request; determining a first identification sequence based on the hash code and the first parameter; determining a target clock callback count value corresponding to the operating system, generating a second identification sequence based on the target callback count value, and obtaining a third identification sequence; generating a target identification based on the first identification sequence, the second identification sequence and the third identification sequence. In this way, since the first parameter is random, the first identification sequence is determined based on the hash code and the first parameter, the second identification sequence is determined based on the target callback count value, and the third identification sequence is irregular and incremental, so that the generated target identification has global uniqueness, and the growth amount of business data cannot be determined from the generated target identification, thereby improving the security of business data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer application technology, and in particular to an identification generation method, apparatus, device, and computer-readable storage medium. Background Art

[0002] In a distributed system, it is usually necessary to generate a globally unique identity document (ID) to uniquely identify data, messages, etc. The globally unique ID is the distributed ID. The distributed ID distinguishes data, messages, etc. in the distributed system from each other to ensure that the distributed system can provide services normally.

[0003] Related technologies typically use the snowflake algorithm to generate distributed IDs. However, this method can generate duplicate IDs when a clock rollback occurs, or when a clock rollback and server restart occur, preventing the distributed system from providing normal services. Furthermore, the IDs generated by this method expose the growing volume of business data in the distributed system, resulting in low security. Summary of the Invention

[0004] In order to solve the above technical problems, the embodiments of the present application hope to provide an identifier generation method that can generate a globally unique identifier and improve the security of business data.

[0005] The technical solution of the embodiment of the application is implemented as follows:

[0006] This embodiment of the present application provides a method for generating an identifier, including:

[0007] receiving an identification sequence generation request, and obtaining a hash code and a first parameter in response to the identification sequence generation request, where the first parameter is random;

[0008] Determine a first identification sequence based on the hash code and the first parameter;

[0009] Determine a target clock callback count value corresponding to the operating system, and generate a second identification sequence based on the target callback count value;

[0010] Acquire a third identification sequence, wherein the third identification sequence changes irregularly and incrementally;

[0011] A target identifier is generated based on the first identifier sequence, the second identifier sequence, and the third identifier sequence.

[0012] The present invention provides an apparatus for generating an identifier, including:

[0013] A first acquisition module is configured to receive an identification sequence generation request, and in response to the identification sequence generation request, acquire a hash code and a first parameter, where the first parameter is random;

[0014] A first determining module, configured to determine a first identification sequence based on the hash code and the first parameter;

[0015] A second determining module is configured to determine a target clock callback count value corresponding to the operating system, and generate a second identification sequence based on the target callback count value;

[0016] A second acquisition module is used to acquire a third identification sequence, where the third identification sequence changes irregularly and incrementally;

[0017] A generating module is configured to generate a target identifier based on the first identifier sequence, the second identifier sequence, and the third identifier sequence.

[0018] The present invention provides an identification generation device, including:

[0019] A memory for storing executable identification generation instructions;

[0020] The processor is used to implement the identifier generation method provided in the embodiment of the present application when executing the executable identifier generation instruction stored in the memory.

[0021] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable identifier generation instructions are stored. The computer-executable identifier generation instructions are configured to execute the identifier generation method provided in the embodiment of the present application.

[0022] The embodiment of the present application provides an identifier generation method, apparatus, device and computer-readable storage medium. Using this technical solution, first, an identifier sequence generation request is received, and in response to the identifier sequence generation request, a hash code and a first parameter are obtained; then, a first identifier sequence is determined based on the hash code and the first parameter; thereafter, a target clock callback count value corresponding to the operating system is determined, a second identifier sequence is generated based on the target callback count value, and a third identifier sequence is obtained; finally, a target identifier is generated based on the first identifier sequence, the second identifier sequence and the third identifier sequence. In this way, since the first parameter is random, the first identifier sequence is determined based on the hash code and the first parameter, and the second identifier sequence is determined based on the target callback count value, so that even if a clock callback occurs, or when a clock callback occurs and a server restart occurs, a non-repeating identifier can be generated. Furthermore, since the first identifier sequence is irregular and changes incrementally, the target identifier generated based on the first identifier sequence, the second identifier sequence and the third identifier sequence is globally unique, and the growth amount of business data cannot be determined from the generated target identifier, thereby improving the security of business data. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A flowchart of a method for generating an identifier provided in an embodiment of the present application;

[0024] Figure 2 A flowchart of a method for generating a target identifier provided in an embodiment of the present application;

[0025] Figure 3 A flow chart of a distributed ID generation method provided in an embodiment of the present application;

[0026] Figure 4 A schematic diagram of the structure of an identification generating device provided in an embodiment of the present application;

[0027] Figure 5 A schematic diagram of the structure of an identification generation device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.

[0029] In order to make the purpose, technical solutions and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0030] In the following description, reference is made to “some embodiments\other embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments\other embodiments” may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.

[0031] In the following description, the terms "first\second\third\fourth" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third\fourth" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0032] Unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by those skilled in the art to which this application belongs. The terms used in this application are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0033] With the popularization of microservices and the rapid iterative development of distributed application systems, the number of middlewares is increasing, and the requirements for ID generation are getting higher and higher. Distributed IDs generally have the following requirements: the ID is globally unique and non-repetitive; the ID generally needs to increase in a global trend; the ID is associated with time, which is conducive to sorting; the growth of business data in the distributed system cannot be determined by the ID.

[0034] In related technologies, a snowflake algorithm is usually used to generate a distributed ID. The ID generated by the snowflake algorithm is composed of three parts. The ID generation steps of this method are as follows:

[0035] First, obtain the current system timestamp accurate to milliseconds, record the current system timestamp, and shift it left by 22 bits through binary shift. These 22 bits are reserved for the machine ID and subsequence part in the second and third steps below, which constitute the first part of the ID; second, obtain the machine ID of the current server. This ID can be a parameter specified or configured when the server is started, or this ID can also be obtained through other middleware, such as Redis, database, etc. The machine ID can also be shifted left by 12 bits through the shift operation. These 12 bits are reserved for the subsequence part. The current machine ID part constitutes the second part of the snowflake algorithm ID; third, the subsequence part, which is usually 10 bits, starts from 0 and increments in steps of 1. Different IDs are generated by self-increasing this subsequence within the same millisecond, which constitutes the third part of the snowflake algorithm ID; fourth, the three parts of the numbers generated in the above three steps are combined through binary OR operations to obtain a complete distributed ID.

[0036] However, the snowflake algorithm has the following problems:

[0037] First, because the server hardware time synchronization will cause the clock to dial back, when the snowflake algorithm is used to obtain the current timestamp of the system, the obtained timestamp will be smaller than the timestamp of the last record. In this case, if this timestamp is continued to be used to generate the ID, a duplicate ID will appear, because this timestamp has been used before. Therefore, the traditional snowflake algorithm will have an exception when processing the clock dial back and cannot provide services normally; second, when the clock dials back, the server happens to be restarted, because the server restart will lose the last timestamp recorded. After the restart, the snowflake algorithm service starts generating IDs from the current timestamp, but the current timestamp has been dialed back to the past and has been used in the service before the restart, so the ID generated at this time will inevitably be repeated; third, the snowflake algorithm can analyze the growth of the system's business data by analyzing the subsequence, because the subsequence is incremented according to the logic of adding 1, it is easy to determine the growth of business data, and the security is relatively low.

[0038] Based on the problems in the related art, an embodiment of the present application provides an identifier generation method, which can generate a globally unique identifier and improve the security of business data.

[0039] The following describes the method for generating an identifier provided by the embodiment of the present application. Figure 1 FIG. 1 is a flow chart of a method for generating an identifier according to an embodiment of the present invention, wherein the method comprises the following steps:

[0040] S101: Receive an identification sequence generation request, and obtain a hash code and a first parameter in response to the identification sequence generation request.

[0041] In some embodiments, the identification sequence generation request may be sent by the server running the distributed system to the server providing the ID generation service when the server generates data, messages and other information and assigns an ID to the data, messages and other information. After receiving the identification sequence generation request, the server providing the ID generation service will respond to the identification sequence generation request and obtain the hash code corresponding to the identification sequence generation request event and the first parameter corresponding to the identification sequence generation event request.

[0042] In some embodiments, the first parameter is random and may be a random integer. The first parameter may be a random integer automatically generated by the system upon receiving an identification sequence generation request event. In some embodiments, for identification sequence generation requests corresponding to different types of received data, messages, or other information, the hash code and the first parameter corresponding to each identification sequence generation request are different.

[0043] S102: Determine a first identification sequence based on the hash code and the first parameter.

[0044] In some embodiments, after obtaining the hash code and the first parameter, the hash code and the first parameter may be further processed to determine a first identification sequence. In some embodiments, the first identification sequence may be a binary sequence, the hash code may be represented by binary data, and the first parameter may be either decimal data or binary data. When the first parameter is decimal data, the decimal data corresponding to the first parameter is converted to binary data. In implementation, the hash code and the binary data corresponding to the first parameter may be XORed to obtain the first identification sequence.

[0045] S103: Determine a target clock callback count value corresponding to the operating system, and generate a second identification sequence based on the target callback count value.

[0046] It should be noted that the target clock rollback count value may be the number of clock rollbacks corresponding to the operating system running on the server providing the ID generation service, that is, the total number of clock rollbacks executed. In some embodiments, clock rollback is related to the Network Time Protocol (NTP) service. The clock corresponding to the operating system may become inaccurate due to various reasons (such as server failure). The NTP service can be used to achieve time calibration, and clock jumps or rollbacks may occur during time calibration.

[0047] For example, if the clock time corresponding to the operating system is 12:30:22 on September 1, 2020, and the standard time is 12:28:25 on September 1, 2020, it means that the clock time corresponding to the operating system lags behind the standard time. The clock corresponding to the operating system can be calibrated through the NTP service so that the clock time corresponding to the operating system is consistent with the standard time. In practice, the clock time corresponding to the previous operating system and the clock time corresponding to the current operating system are compared. If the current corresponding clock time is earlier than the previous corresponding clock time, it can be determined that a clock dialback has occurred. In practice, the sum of the number of clock dialbacks before the current moment can be determined as the target clock dialback count value corresponding to the target operating system.

[0048] In some embodiments, after obtaining the target clock callback count value corresponding to the operating system, a second identification sequence can be generated based on the target callback count value. In some embodiments, the second identification sequence can be binary data. During implementation, the binary data corresponding to the target callback count value can be directly determined as the second identification sequence.

[0049] S104: Obtain a third identification sequence.

[0050] In some embodiments, the third identification sequence changes irregularly and incrementally. The third identification sequence can be a binary sequence. The binary value sequence includes 12 bits, the first two bits constitute the first part of the third identification sequence, and the last ten bits constitute the first part of the third identification sequence. The first part can be any one of the binary data 00, 01, 10, 11, and the second part can start from any position from 0 to 1024 and increase in steps of 1, 2, etc., so that the third identification sequence changes irregularly and incrementally.

[0051] S105: Generate a target identifier based on the first identifier sequence, the second identifier sequence, and the third identifier sequence.

[0052] In some embodiments, after obtaining the first, second, and third identification sequences, a target identification sequence can be generated based on the first, second, and third identification sequences. The target identification sequence can be an ID corresponding to a message, information, etc. The first, second, and third identification sequences can all be binary sequences, and thus the target identification sequence composed of the first, second, and third identification sequences is also a binary sequence.

[0053] In the identifier generation method provided in the embodiment of the present application, first, an identifier sequence generation request is received, and in response to the identifier sequence generation request, a hash code and a first parameter are obtained; then, a first identifier sequence is determined based on the hash code and the first parameter; thereafter, a target clock callback count value corresponding to the operating system is determined, a second identifier sequence is generated based on the target callback count value, and a third identifier sequence is obtained; finally, a target identifier is generated based on the first identifier sequence, the second identifier sequence, and the third identifier sequence. In this way, since the first parameter is random, the first identifier sequence is determined based on the hash code and the first parameter, and the second identifier sequence is determined based on the target callback count value, so that even if a clock callback occurs, or when a clock callback occurs and a server restart occurs, a non-repeating identifier can be generated. Furthermore, since the first identifier sequence is irregular and changes incrementally, the target identifier generated based on the first identifier sequence, the second identifier sequence, and the third identifier sequence is globally unique, and the growth amount of business data cannot be determined from the generated target identifier, thereby improving the security of business data.

[0054] In some embodiments of the present application, the first identification sequence is determined based on the hash code and the first parameter, that is, the above-mentioned step S102 can also be implemented through the following steps S1021 to S1023, and each step is described below.

[0055] S1021. Determine a binary sequence corresponding to the first parameter.

[0056] It should be noted that the first parameter is random and can be any positive integer. For example, the first parameter can be 5, 12, 16, etc. The first parameter is a decimal number. Therefore, after obtaining the first parameter, the binary number corresponding to the first parameter can be further determined. This binary data is the binary sequence. In some embodiments, determining the binary sequence corresponding to the first parameter can be performed by converting the decimal number corresponding to the first parameter into a binary number. For example, if the first parameter is 5, the binary number corresponding to the first parameter is 00000101, that is, the binary sequence corresponding to the first parameter is 00000101.

[0057] S1022: Perform an XOR operation on the hash code and the binary sequence corresponding to the first parameter to obtain a candidate identification sequence.

[0058] In some embodiments, the hash code can be represented by a binary sequence. Therefore, after obtaining the hash code and the binary sequence corresponding to the first parameter, the hash code and the binary sequence corresponding to the first parameter can be XORed, and the structure obtained after the XOR processing is determined as the candidate identification sequence. For example, if the hash code is 00011011 and the binary sequence corresponding to the first parameter is 00000101, the result of the XOR processing of the hash code and the binary sequence corresponding to the first parameter is 000110110, that is, 000110110 is the candidate identification sequence.

[0059] S1023: Determine the candidate identifier sequence as the first identifier sequence.

[0060] In some embodiments, after obtaining a candidate identification sequence, the candidate identification sequence can be determined as a first identification sequence. In some embodiments, the first identification sequence is 32 bits, i.e., the first identification sequence occupies four 8-bit binary numbers. In practice, if the candidate identification sequence is 8 bits, for example, the candidate identification sequence is 000110110, the corresponding high-order bits of the candidate identification sequence can be padded with zeros to obtain 0000000000000000000000000000110110, thereby obtaining a 32-bit first identification sequence.

[0061] It can be understood that in the embodiment of the present application, since the hash code and the first parameter are both associated with the identification sequence generation request event, and the hash code will change each time the server is restarted, the candidate identification sequence obtained by XORing the hash code and the binary sequence corresponding to the first parameter, that is, the first identification sequence, is more random, avoiding the repetition of the target identification sequence determined based on the first identification sequence, and ensuring the uniqueness of the target identification sequence.

[0062] In some embodiments of the present application, the target clock callback count value corresponding to the operating system is determined, and a second identification sequence is generated based on the target callback count value. That is, the above-mentioned step S103 can also be implemented by the following steps S1031 to S1033. Each step is described below.

[0063] S1031. Obtain the first callback count value corresponding to the current moment, and obtain the reference timestamp corresponding to the operating system at the previous moment.

[0064] In some embodiments, the first dial-back count value is the number of clock dial-back operations performed before the current moment, that is, the total number of clock dial-back operations performed before the current moment, and can be the number of clock dial-back operations corresponding to the initial timestamp corresponding to the operating system and the current moment. The reference timestamp corresponding to the operating system at the previous moment is the timestamp corresponding to the operating system at the moment before the current moment.

[0065] In some embodiments, each time a clock rollback is executed, a timestamp corresponding to the operating system at the time of the clock rollback can be recorded. When determining whether a clock rollback has occurred, the timestamp corresponding to the current timestamp and the previous timestamp can be compared. If the recorded previous timestamp is later than the current timestamp, a clock rollback is determined to have occurred. When determining the first rollback count value, the system can start with an initial timestamp corresponding to the operating system, where the clock rollback count value corresponding to the initial timestamp is 0, and compare adjacent timestamps in sequence. If a clock rollback is determined to have occurred, the rollback count value is increased by 1, and finally a total clock rollback count value, i.e., the first rollback count value, is obtained.

[0066] S1032: Obtain the timestamp corresponding to the operating system at the current moment. If the timestamp corresponding to the operating system at the current moment is earlier than the reference timestamp, add 1 to the first callback count value to obtain the target clock callback count value.

[0067] In some embodiments, after obtaining the timestamp corresponding to the operating system at the current moment and the reference timestamp corresponding to the previous moment, the size relationship between the timestamp corresponding to the operating system at the current moment and the reference timestamp can be further determined. If the timestamp corresponding to the operating system at the current moment is earlier than the reference timestamp, for example, the timestamp corresponding to the current moment is 14:35:05 on February 13, 2021, and the reference timestamp is 14:36:18 on February 13, 2021, it can be determined that a clock callback occurred between the current moment and the previous moment. At this time, the first callback count value can be added by 1 to obtain the target clock callback count value.

[0068] S1033: Convert the target clock dial-back count value into a binary sequence, and determine the binary sequence as a second identification sequence.

[0069] It should be noted that the clock dial back count value is a non-negative integer, which corresponds to a decimal number, such as 0, 5, 8, 12, etc. Therefore, in some embodiments, after obtaining the target clock dial back count value, the target clock dial back count value can be converted into a binary number to obtain a binary sequence, and the binary sequence is used as the first identification sequence.

[0070] In some embodiments, the second identification sequence is a 4-bit binary sequence, that is, the binary number range corresponding to the second identification sequence is 0000-1111, and its corresponding decimal number is 0-16, that is, the value range corresponding to the target clock callback count value is any non-negative integer in [0,10].

[0071] It can be understood that in the embodiment of the present application, by converting the total clock callback count value corresponding to the current moment and the time before the current moment (target clock callback count value) into a binary sequence, and using the binary sequence as the first identification sequence, the first identification sequence includes the number of clock callbacks, thereby avoiding the problem of generating duplicate target identifiers after the clock callback occurs, and ensuring the global uniqueness of the target identifier.

[0072] In some embodiments of the present application, obtaining the third identification sequence, that is, the above-mentioned step S104 can also be implemented through the following steps S1041 to S1043, and each step is described below.

[0073] S1041: Obtain a preset sequence code, and determine a first sequence code based on a preset auto-increment rule.

[0074] In some embodiments, the preset sequence code can be a 10-bit binary sequence, which can be a binary sequence corresponding to any non-negative integer in the decimal number 0-1024, for example, it can be 0000000000 (corresponding to decimal number 0), 0000000110 (corresponding to decimal number 6), 1000000000 (corresponding to decimal number 512), etc.

[0075] In some embodiments, the preset auto-increment rule may be to auto-increment the preset sequence code using a varying step size, where the varying step size may be any positive integer less than 1024, such as 1, 2, or 3. The preset auto-increment rule causes the first sequence code to vary irregularly and incrementally. For example, if the preset sequence code is 0000000001, and the preset auto-increment rule causes the preset sequence code to increment alternately using varying step sizes of 1 and 2, then successively obtained first sequence codes may be 0000000010, 0000000011, 0000000100, and so on.

[0076] S1042: Acquire a third parameter, determine a sequence code corresponding to the third parameter, and combine the sequence code corresponding to the third parameter with the first sequence code to obtain a second sequence code.

[0077] In some embodiments, the third parameter is random and can be any one of 0, 1, 2, and 3. After obtaining the third parameter, a binary number corresponding to the third parameter can be determined. This binary number is the sequence code corresponding to the third parameter. In some embodiments, the sequence code corresponding to the third parameter occupies 2 bits. For example, if the obtained third parameter is 2, the sequence code corresponding to the third parameter is 10. Of course, the sequence code corresponding to the third parameter here is only illustrative and is not limited to this application.

[0078] In some embodiments, after obtaining the first sequence code and the sequence code corresponding to the third parameter, the first sequence code and the sequence code corresponding to the third parameter can be combined to obtain a second sequence code. In some embodiments, combining the first sequence code and the sequence code corresponding to the third parameter can be performed by combining the first sequence code and the sequence code corresponding to the third parameter to obtain the second sequence code. The number of bits corresponding to the second sequence code is the sum of the number of bits occupied by the first sequence code and the number of bits occupied by the sequence code corresponding to the third parameter. For example, if the number of bits occupied by the first sequence code is 10 and the number of bits occupied by the sequence code corresponding to the third parameter is 2, the number of bits corresponding to the second sequence code is 12.

[0079] In some embodiments, when the sequence code corresponding to the third parameter and the first sequence code are combined, the sequence code corresponding to the third parameter can be determined as a high-order sequence, and the first sequence code can be determined as a low-order sequence. For example, if the sequence code corresponding to the third parameter is 00 and the first sequence code is 0000000010, the second sequence code obtained after the combination is 000000000010.

[0080] S1043: Determine the second sequence code as a third identification sequence.

[0081] In some embodiments, after obtaining the second sequence code, the second sequence code can be determined as the third identification sequence. In some embodiments, the third identification sequence is a 12-bit binary sequence. When the second sequence code is a 12-bit binary sequence, the second sequence code can be directly determined as the third identification sequence.

[0082] It can be understood that in the embodiment of the present application, since the first sequence code changes irregularly and incrementally, and the third parameter is random, the second sequence code determined based on the sequence code corresponding to the first sequence and the third parameter, that is, the third identification sequence, is also random and changes irregularly and incrementally, making it impossible to determine the growth amount of business data from the target identifier determined by the third identification sequence, thereby ensuring the security of the business data.

[0083] In some embodiments of the present application, "combining the sequence code corresponding to the third parameter and the first sequence code to obtain the second sequence code" in step S1042 can also be implemented through the following steps S201 to S203, and each step is described below.

[0084] S201: Shift the sequence code corresponding to the third parameter left by a first preset number of bits to obtain a reference sequence code.

[0085] It should be noted that the first preset number of bits is the number of bits of the first sequence code, that is, the number of binary bits occupied by the first sequence code. In some embodiments, when the sequence code corresponding to the third parameter and the first sequence code are combined, the sequence code corresponding to the third parameter can be left-shifted by the number of bits of the first sequence code to obtain a reference sequence code, such that the sequence code corresponding to the third parameter is used as the high-order sequence and the first sequence code is used as the low-order sequence. For example, if the sequence code corresponding to the third parameter is 01 and the number of bits corresponding to the first sequence code is 10, then the reference sequence code obtained by left-shifting the sequence code corresponding to the third parameter by the first preset number of bits is 010000000000.

[0086] S202: Perform an OR operation on the reference sequence code and the first sequence code to obtain a candidate sequence code.

[0087] In some embodiments, after obtaining the reference sequence code and the first sequence code, an OR operation can be performed on the reference sequence code and the first sequence code, and the sequence code obtained after the OR operation is determined as the candidate sequence code. For example, if the reference sequence code is 010000000000 and the first sequence code is 0000000010, the candidate sequence code obtained after performing the OR operation on the reference sequence code and the first sequence code is 010000000010.

[0088] S203: Determine the candidate sequence code as the second sequence code.

[0089] In some embodiments, after obtaining the candidate sequence code, the candidate sequence code may be determined as the second sequence code. In some embodiments, the candidate sequence is a 12-bit binary sequence, and the second sequence code determined by the candidate sequence code is also 12 bits.

[0090] In some embodiments of the present application, Figure 2 As shown in FIG. 1 , a flow chart of a method for generating a target identifier provided by an embodiment of the present application is provided. After receiving an identifier sequence generation request, responding to the identifier sequence generation request, obtaining a hash code and a first parameter, that is, step S101, the following steps may also be performed: Figure 2 The following steps S301 to S304 are described below.

[0091] S301: Obtain an initial timestamp corresponding to the operating system and a timestamp corresponding to the current moment.

[0092] It should be noted that the initial timestamp corresponding to the operating system may be the timestamp corresponding to the server providing the distributed ID generation service, and the initial timestamp may be the timestamp recorded when the server first starts working. In some embodiments, when obtaining the initial timestamp corresponding to the operating system, the timestamp corresponding to the current moment may also be obtained simultaneously. In some embodiments, the initial timestamp corresponding to the operating system and the timestamp corresponding to the current moment may be obtained through an interface function provided by the server. In other embodiments, the initial timestamp corresponding to the operating system may also be obtained from a preset storage area, which pre-stores the initial timestamp corresponding to the operating system.

[0093] S302: Determine the time difference between the initial timestamp and the timestamp corresponding to the current moment.

[0094] In some embodiments, after obtaining the initial timestamp and the timestamp corresponding to the current moment, the time difference between the initial timestamp and the timestamp corresponding to the current moment can be further determined, and the time difference can be expressed in milliseconds. For example, when the initial timestamp is 05:20:02 on October 1, 2021, and the timestamp corresponding to the current moment is 10:25:16 on October 5, 2021, the time difference between the initial timestamp and the timestamp corresponding to the current moment is 4 days, 5 hours, 5 minutes, and 14 seconds, which, when converted to milliseconds, corresponds to a time difference of 363,914,000 milliseconds.

[0095] S303: Determine a fourth identification sequence based on the time difference.

[0096] In some embodiments, the fourth identification sequence is a binary sequence. After obtaining the time difference, the decimal number corresponding to the time difference can be converted into a binary number, and then the binary number is determined as the first identification sequence. For example, if the time difference is 32769 milliseconds, the binary number of the time difference is 10000000000000001. In some embodiments, the first identification sequence corresponds to 64 bits, that is, there are a total of 2^64 timestamps. These 2^64 timestamps can provide multiple different distributed IDs.

[0097] S304: Generate a target identifier based on the first identifier sequence, the second identifier sequence, the third identifier sequence, and the fourth identifier sequence.

[0098] In some embodiments, after the first identification sequence, the second identification sequence, the third identification sequence, and the fourth identification sequence are obtained, a target identification may be generated based on the first identification sequence, the second identification sequence, the third identification sequence, and the fourth identification sequence.

[0099] It is understandable that since the fourth identification sequence is determined based on the time difference between the initial timestamp and the timestamp corresponding to the current moment, the target identification generated based on the third identification sequence can reflect the increase in time, ensuring the incremental nature of the target identification.

[0100] In some embodiments of the present application, a target identifier is generated based on the first identifier sequence, the second identifier sequence, the third identifier sequence, and the fourth identifier sequence. That is, the above-mentioned step S304 can also be implemented through the following steps S3041 to S3045. Each step is described below.

[0101] S3041. Shift the fourth identification sequence left by a second preset number of bits to obtain a first reference identification sequence.

[0102] It should be noted that the second preset number of bits is the sum of the number of bits in the first identification sequence, the number of bits in the second identification sequence, and the number of bits in the third identification sequence. In some embodiments, by left-shifting the third identification sequence by the second preset number of bits, the fourth identification sequence can be used as the high-order sequence of the target identification sequence, i.e., the fourth identification sequence is determined as the first part of the target identification. For example, if the number of bits in the first identification sequence, the number of bits in the second identification sequence, and the number of bits in the third identification sequence are 32, 4, and 12, respectively, the fourth identification sequence can be left-shifted by 48 bits to obtain the first reference identification sequence.

[0103] S3042: Shift the first identification sequence left by a third preset number of bits to obtain a second reference identification sequence.

[0104] In some embodiments, the third preset number of bits is the sum of the number of bits in the second identification sequence and the number of bits in the third identification sequence. By left-shifting the first identification sequence by the third preset number of bits, the first identification sequence can be determined as the reference portion of the target identification. For example, if the number of bits in the second identification sequence and the number of bits in the third identification sequence are 4 and 12, respectively, the third preset number of bits is 16. In practice, the first identification sequence can be left-shifted by 16 bits to obtain the second reference identification sequence. For example, if the first identification sequence is a 12-bit binary sequence: 000000000011, then the second reference identification sequence obtained by left-shifting the first identification sequence by the third preset number of bits is 0000000000110000000000000000.

[0105] S3043: Shift the second identification sequence left by a fourth preset number of bits to obtain a third reference identification sequence.

[0106] In some embodiments, the fourth predetermined number of bits is the number of bits in the third identification sequence. By left-shifting the second identification sequence by the fourth predetermined number of bits, the second identification sequence can be used as the third part of the target identification. For example, if the second identification sequence is a 4-bit binary sequence: 0010, and the third identification sequence has 12 bits (i.e., the fourth predetermined number of bits is 12), then the third reference identification sequence obtained by left-shifting the second identification sequence by 12 bits is: 0010000000000000.

[0107] S3044. Perform an OR operation on the first reference identifier sequence, the second reference identifier sequence, the third reference identifier sequence, and the third identifier sequence to obtain a target identifier sequence.

[0108] In some embodiments, after obtaining the first reference identifier sequence, the second reference identifier sequence, and the third reference identifier sequence, an OR operation can be performed on the first reference identifier sequence, the second reference identifier sequence, the third reference identifier sequence, and the third identifier sequence to obtain a target identifier sequence. By performing an OR operation on the first reference identifier sequence, the second reference identifier sequence, the third reference identifier sequence, and the third identifier sequence, the fourth identifier sequence, the first identifier sequence, the second identifier sequence, and the third identifier sequence can be used as the first, second, third, and fourth parts of the target identifier sequence, respectively, with the first to fourth parts corresponding to the highest to lowest bits of the target identifier sequence.

[0109] S3045. Determine the target identification sequence as the target identification.

[0110] In some embodiments, after obtaining a target identification sequence, the target identification sequence can be determined as a target identification, i.e., an ID corresponding to information such as data or a message. For example, if the number of bits corresponding to the first identification sequence, the second identification sequence, the third identification sequence, and the fourth identification sequence are 32, 4, 12, and 64, respectively, and the total number of bits corresponding to the first identification sequence, the second identification sequence, the third identification sequence, and the fourth identification sequence is 112, then the target identification sequence has 112 bits, and the target identification is a 112-bit binary identification sequence.

[0111] In the identifier generation method provided in the embodiment of the present application, first, an identifier sequence generation request is received, and in response to the identifier sequence generation request, a hash code and a first parameter are obtained; then, a first identifier sequence is determined based on the hash code and the first parameter; thereafter, a target clock callback count value corresponding to the operating system is determined, a second identifier sequence is generated based on the target callback count value, and a third identifier sequence is obtained; finally, a target identifier is generated based on the first identifier sequence, the second identifier sequence, and the third identifier sequence. In this way, since the first parameter is random, the first identifier sequence is determined based on the hash code and the first parameter, and the second identifier sequence is determined based on the target callback count value, so that even if a clock callback occurs, or when a clock callback occurs and a server restart occurs, a non-repeating identifier can be generated. Furthermore, since the first identifier sequence is irregular and changes incrementally, the target identifier generated based on the first identifier sequence, the second identifier sequence, and the third identifier sequence is globally unique, and the growth amount of business data cannot be determined from the generated target identifier, thereby improving the security of business data.

[0112] The following describes the implementation process of the embodiment of the present application in actual application scenarios.

[0113] In some embodiments, as Figure 3 FIG. 4 is a flow chart of a distributed ID generation method according to an embodiment of the present application. The distributed ID generation method according to an embodiment of the present application can be implemented by the following steps S401 to S405, each of which is described below.

[0114] S401: Determine whether an ID generation request (identification sequence generation request) is received, and obtain a hash code and a random integer (first parameter) corresponding to the current instance.

[0115] In some embodiments, the ID generation request may be sent by a system providing a distributed ID generation service within a distributed system. For example, the ID generation request may be sent by a server operating within the distributed system to a server providing the distributed ID generation service, for assigning an ID to data generated by the distributed system. In some embodiments, the current instance may be an ID generation request event, each corresponding hash code to an ID generation request event being different. The random integer may be any non-negative integer. Upon receiving the ID generation request, the system generates a random integer.

[0116] S402: Determine a first identification sequence code (first identification sequence) based on the hash code and the random integer.

[0117] In some embodiments, after obtaining the hash code and the random integer, the first identification sequence code can be determined based on the hash code and the random integer (the first identification sequence is determined based on the hash code and the first parameter). During implementation, the hash code and the random integer can be XORed, and the identification sequence obtained after the XOR processing can be determined as the first identification sequence code (the hash code and the binary sequence corresponding to the first parameter are XORed to obtain a candidate identification sequence; the candidate identification sequence is determined as the first identification sequence).

[0118] In some embodiments, the random integer can be first converted into a binary sequence, and then the hash code and the binary sequence can be XORed to obtain the XORed binary sequence, and the XORed binary sequence can be stored. The XORed binary sequence can be determined as the second part corresponding to the target identifier.

[0119] S403: Obtain a timestamp corresponding to the current moment of the service system (a timestamp corresponding to the current moment of the operating system), and determine a second identification sequence code (a fourth identification sequence) based on the timestamp.

[0120] It should be noted that the timestamp corresponding to the current moment of the service system can be the timestamp of the server providing the ID generation service. After obtaining the timestamp corresponding to the current moment of the service system, the time difference between the timestamp corresponding to the current moment of the service system and the initial timestamp of the server providing the ID generation service (the initial timestamp corresponding to the operating system) can be determined (the time difference between the initial timestamp and the timestamp corresponding to the current moment is determined), and the binary sequence corresponding to the time difference is determined as the second identification sequence (based on the time difference, the fourth identification sequence is determined).

[0121] In some embodiments, for example, if the initial timestamp and current timestamp corresponding to the current moment of the service system are 12:35:05 on December 5, 2021 and 16:57:08 on December 7, 2021, respectively, then the time difference between the initial timestamp and the current timestamp is 2 days, 4 hours, 22 minutes and 3 seconds, which corresponds to 188523000 milliseconds when the time difference is in milliseconds. Afterwards, the time difference can be converted into a binary sequence to obtain a second identification sequence code.

[0122] S404: Acquire the number of clock dial-back counts (target clock dial-back count value), and determine a third identification sequence code (second identification sequence) based on the number of clock dial-back counts.

[0123] In some embodiments, the number of clock callback counts can be the total count value of clock callbacks that occurred before the timestamp corresponding to the current moment. In practice, the size between two adjacent timestamps can be determined starting from the initial timestamp. For example, if the timestamp corresponding to the i-th moment (i=0, 1, ..., N, N is a positive integer) is 12:35:05 on December 5, 2021, and the timestamp corresponding to the i+1-th moment is 12:30:56 on December 5, 2021, then it is determined that a clock callback occurred at the i+1-th moment. After traversing the timestamps corresponding to N moments, the total number of clock callbacks, that is, the number of clock callback counts, can be obtained. After obtaining the number of clock callback counts, the binary sequence corresponding to the clock callback count can be determined as the third identification sequence code (the target clock callback count value is converted into a binary sequence, and the binary sequence is determined as the second identification sequence).

[0124] In some embodiments, the callback counter bit can be initially set to 0000, corresponding to a 4-bit binary number. If the timestamp obtained at the current moment is less than the timestamp corresponding to the previous moment, it indicates that a clock callback has occurred, and the callback counter bit can be increased by 1. In practice, a 4-bit binary number can support 16 clock callbacks in a short period of time. In practice, if the number of clock callbacks exceeds 16 in a short period of time, it indicates that clock synchronization is abnormal, and it can be determined that the server system providing the ID generation service has a hardware failure, requiring manual intervention.

[0125] S405: Obtain a fourth identification sequence code (third identification sequence), and generate a target ID (target identification) based on the first identification sequence code, the second identification sequence code, the third identification sequence code, and the fourth identification sequence code.

[0126] In some embodiments, the fourth identification sequence may be a subsequence, which may be 12 bits and may include two parts. The first part may be a 2-bit binary sequence (the sequence code corresponding to the third parameter), for example, any one of 00, 01, 10, and 11. In practice, within each millisecond, the system's random number may be used to set these 2 bits to start at 00, 01, 10, or 11. The second part may be a 10-bit binary sequence, and the starting value of the 10 bits may be set to start at any position between 0 and 1024 each time. The increment step size is also not fixed (the first sequence code is determined based on a preset auto-increment rule), for example, it may increase by 1, 2, or other positive integer values ​​each time. The first part is then determined as the high bit of the fourth identification sequence, and the second part is determined as the low bit of the fourth identification sequence, to generate the fourth identification sequence. In this way, the generated fourth identification sequence exhibits an increasing trend and irregular changes.

[0127] In some embodiments, after obtaining the first identification sequence code, the second identification sequence code, the third identification sequence code, and the fourth identification sequence code, the second identification sequence code, the first identification sequence code, the third identification sequence code, and the fourth identification sequence code can be left-shifted respectively, and a binary OR operation can be performed to obtain the final target identification (the target identification is generated based on the first identification sequence, the second identification sequence, the third identification sequence, and the fourth identification sequence). For example, if the first identification sequence code, the second identification sequence code, the third identification sequence code, and the fourth identification sequence code are represented by P1, P2, P3, and P4, respectively, and the number of bits corresponding to P1, P2, P3, and P4 are 32, 64, 4, and 12, respectively, then the target identification I determined based on P1, P2, P3, and P4 can be expressed by the following formula (1):

[0128] I=(P2<<48)|(P1<<16)|(P3<<12)|P4 (1);

[0129] Among them, << represents the left shift operator, for example, P1<<16 means shifting P1 left by 16 bits, and | represents the OR operator.

[0130] It is understood that in this embodiment of the present application, by adding a clock rollback digit to the target identification sequence, a non-duplicate ID with an increasing trend can be provided even when a clock rollback occurs. Furthermore, if the clock rollback service happens to be restarted, the addition of the hash code corresponding to the first identification sequence can still provide a non-duplicate ID. Furthermore, the fourth identification sequence uses a random initial value every millisecond to avoid exposing the growth of service data, thereby improving the security of service data.

[0131] In some embodiments, the ID generation method provided in the embodiments of the present application does not require the introduction of any additional components, and does not even require a separate distributed service to provide it. It can be integrated into each distributed system as a software development kit (SDK) for independent use. Of course, this solution is not as good as the trend of incrementality provided by a separate service in obtaining timestamps. In actual use, the SDK corresponding to the ID generation method provided by this application can be integrated into each distributed system. At the same time, a separate service can also be deployed for each distributed system to call to generate an ID. When a problem occurs in the service, it can be fused, and each distributed system can degenerate into using the SDK to generate its own ID, which can also ensure the trend of incrementality and uniqueness.

[0132] This application also provides an identification generation device, Figure 4 A schematic diagram of the structure of an identification generating device provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the identification generating device 500 includes:

[0133] A first acquisition module 501 is configured to receive an identification sequence generation request, and in response to the identification sequence generation request, acquire a hash code and a first parameter, where the first parameter is random;

[0134] A first determining module 502, configured to determine a first identification sequence based on the hash code and the first parameter;

[0135] A second determining module 503 is configured to determine a target clock callback count value corresponding to the operating system, and generate a second identification sequence based on the target callback count value;

[0136] A second acquisition module 504 is configured to acquire a third identification sequence, wherein the third identification sequence changes irregularly and incrementally;

[0137] The generating module 505 is configured to generate a target identifier based on the first identifier sequence, the second identifier sequence, and the third identifier sequence.

[0138] It should be noted that the description of the identification generation device in the embodiment of the present application is similar to the description of the method embodiment described above, and has similar beneficial effects as the method embodiment, so it will not be repeated here. For technical details not disclosed in the embodiment of the present device, please refer to the description of the method embodiment of the present application for understanding.

[0139] It should be noted that, in the embodiment of the present application, if the above-mentioned control method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.

[0140] Accordingly, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the identifier generation method provided in the above embodiment.

[0141] The present application also provides an identification generating device. Figure 5 A schematic diagram of the structure of an identification generating device provided in an embodiment of the present application is shown as follows: Figure 5As shown, the identifier generation device 600 includes: a memory 601, a processor 602, a communication interface 603, and a communication bus 604. The memory 601 is used to store executable identifier generation instructions; the processor 602 is used to execute the executable identifier generation instructions stored in the memory to implement the identifier generation method provided in the above embodiment.

[0142] The description of the above identification generation device and storage medium embodiments is similar to the description of the above method embodiments and has similar beneficial effects as the method embodiments. For technical details not disclosed in the identification generation device and storage medium embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0143] It should be understood that “some embodiments” or “an embodiment” mentioned throughout the specification means that specific features, structures or characteristics related to the embodiments are included in at least one embodiment of the present application. Therefore, “in some embodiments” or “in an embodiment” appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.

[0144] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0145] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0146] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0147] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above-mentioned integrated units can be implemented in the form of hardware or in the form of hardware plus software functional units.

[0148] Those skilled in the art will understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiments; and the aforementioned storage medium includes: mobile storage devices, ROM, disks or optical disks, and other media that can store program codes.

[0149] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a product to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks or optical disks.

[0150] The above is merely an embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A method for generating an identifier, characterized in that: include: receiving an identification sequence generation request, and obtaining a hash code and a first parameter in response to the identification sequence generation request, where the first parameter is random; Determine a first identification sequence based on the hash code and the first parameter; Determine a target clock dial-back count value corresponding to the operating system, and generate a second identification sequence based on the target clock dial-back count value; Acquire a third identification sequence, wherein the third identification sequence changes irregularly and incrementally; generating a target identifier based on the first identifier sequence, the second identifier sequence, and the third identifier sequence; Determining the first identification sequence based on the hash code and the first parameter includes: determining a binary sequence corresponding to the first parameter; performing an XOR operation on the hash code and the binary sequence corresponding to the first parameter to obtain a candidate identification sequence; and determining the candidate identification sequence as the first identification sequence; Determining a target clock dial-back count value corresponding to the operating system and generating a second identification sequence based on the target clock dial-back count value includes: obtaining a first dial-back count value corresponding to a current moment and obtaining a reference timestamp corresponding to the operating system at the previous moment, wherein the first dial-back count value is the number of times the clock dial-back operation was performed before the current moment; obtaining a timestamp corresponding to the operating system at the current moment, and if the timestamp corresponding to the operating system at the current moment is earlier than the reference timestamp, adding 1 to the first dial-back count value to obtain the target clock dial-back count value; converting the target clock dial-back count value into a binary sequence, and determining the binary sequence as the second identification sequence; The obtaining of the third identification sequence includes: obtaining a preset sequence code, determining a first sequence code based on a preset auto-increment rule, wherein the preset auto-increment rule causes the first sequence code to change irregularly and incrementally; obtaining a third parameter, determining a sequence code corresponding to the third parameter, and combining the sequence code corresponding to the third parameter with the first sequence code to obtain a second sequence code, wherein the third parameter is random, the sequence code corresponding to the third parameter is a high-order sequence, and the first sequence code is a low-order sequence; and determining the second sequence code as the third identification sequence.

2. The method according to claim 1, characterized in that The combining the sequence code corresponding to the third parameter and the first sequence code to obtain a second sequence code includes: Shifting the sequence code corresponding to the third parameter left by a first preset number of bits to obtain a reference sequence code, where the first preset number of bits is the number of bits of the first sequence code; Performing an OR operation on the reference sequence code and the first sequence code to obtain a candidate sequence code; The candidate sequence code is determined as the second sequence code.

3. The method according to claim 1, characterized in that Also includes: Obtaining an initial timestamp corresponding to the operating system and a timestamp corresponding to the current moment; Determine a time difference between the initial timestamp and the timestamp corresponding to the current moment; determining a fourth identification sequence based on the time difference; A target identifier is generated based on the first identifier sequence, the second identifier sequence, the third identifier sequence, and the fourth identifier sequence.

4. The method according to claim 3, characterized in that The generating a target identifier based on the first identifier sequence, the second identifier sequence, the third identifier sequence, and the fourth identifier sequence includes: Shifting the fourth identification sequence left by a second preset number of bits to obtain a first reference identification sequence, where the second preset number of bits is the sum of the number of bits of the first identification sequence, the number of bits of the second identification sequence, and the number of bits of the third identification sequence; Shifting the first identification sequence left by a third preset number of bits to obtain a second reference identification sequence, where the third preset number of bits is the sum of the number of bits of the second identification sequence and the number of bits of the third identification sequence; Shifting the second identification sequence left by a fourth preset number of bits to obtain a third reference identification sequence, where the fourth preset number of bits is the number of bits of the third identification sequence; Performing an OR operation on the first reference identifier sequence, the second reference identifier sequence, the third reference identifier sequence, and the third identifier sequence to obtain a target identifier sequence; The target identification sequence is determined as the target identification.

5. An identification generating device comprising: A first acquisition module is configured to receive an identification sequence generation request, and acquire a hash code and a first parameter in response to the identification sequence generation request, where the first parameter is random; a first determining module, configured to determine a binary sequence corresponding to the first parameter; perform an XOR operation on the hash code and the binary sequence corresponding to the first parameter to obtain a candidate identification sequence; and determine the candidate identification sequence as a first identification sequence; A second determining module is configured to obtain a first callback count value corresponding to a time before the current moment, and obtain a reference timestamp corresponding to the operating system at the previous moment, wherein the first callback count value is the number of times the clock callback operation was performed before the current moment; obtain a timestamp corresponding to the operating system at the current moment, and if the timestamp corresponding to the operating system at the current moment is earlier than the reference timestamp, increment the first callback count value by 1 to obtain a target clock callback count value; Converting the target clock dial-back count value into a binary sequence, and determining the binary sequence as a second identification sequence; A second acquisition module is configured to acquire a preset sequence code and determine a first sequence code based on a preset auto-increment rule, wherein the preset auto-increment rule causes the first sequence code to change irregularly and incrementally; Obtaining a third parameter, determining a sequence code corresponding to the third parameter, and combining the sequence code corresponding to the third parameter with the first sequence code to obtain a second sequence code, wherein the third parameter is random, the sequence code corresponding to the third parameter is a high-order sequence, and the first sequence code is a low-order sequence; determining the second sequence code as a third identification sequence; and wherein the third identification sequence exhibits irregular and increasing variation. A generating module is configured to generate a target identifier based on the first identifier sequence, the second identifier sequence, and the third identifier sequence.

6. A device for generating an identifier, characterized in that: include: A memory for storing executable identification generation instructions; A processor, configured to implement the method according to any one of claims 1 to 4 when executing the generation of the executable identifier stored in the memory.

7. A computer-readable storage medium, characterized in that The device stores an identifier generation instruction for causing a processor to implement the method according to any one of claims 1 to 4 when executing the instruction.

Citation Information

Patent Citations

  • Compositions and method for measuring and calibrating amplification bias in multiplexed pcr reactions

    CN104520440A

  • Global unique ID generation method and device and vehicle management system

    CN111831639A