Identification generation method and device, computer equipment, storage medium and program product
Through encryption and encoding processing, combined with time stamps, node numbers and serial numbers, the uniqueness and security of object identification in the prior art are solved, and efficient and secure identification generation is achieved.
Patent Information
- Application Number
- CN202411192316.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-02
- Publication Date
- 2024-12-06
AI Technical Summary
When generating business object identifiers in the prior art, random number schemes, UUID schemes and database-based schemes are difficult to ensure the uniqueness of object identifiers. The snowflake algorithm may have clock callback problems, resulting in duplication of object identifiers and difficulty in ensuring uniqueness.
The object identifier is generated by encryption and encoding processing. By encrypting and encoding the identification generation information (including timestamps, node numbers and serial numbers), a unique and secure object identifier is generated, and if necessary, a random identifier and version are added. Identify and verify the mark to improve the security and life of the mark.
It effectively ensures the uniqueness and security of business object identification, optimizes the identification attributes, extends the usage period of the identification, and improves the identification generation efficiency.
Smart Images

Figure CN119089466A_ABST
Abstract
Description
[0001] This application is a divisional application of the Chinese patent application filed on April 2, 2024 with application number 202410389961.X, and application name “Identification generation method, device and computer equipment, storage medium, program product”, and all the contents are incorporated into this application by reference. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a method and apparatus for generating an identifier, a computer device, a storage medium, and a program product. Background Art
[0003] The business system can generate an object identifier for a business object. The purpose of generating an object identifier is to expect that the object identifier can uniquely identify the business object in the business system. At present, the schemes for the business system to generate object identifiers for business objects may include any of the following: ① Random number scheme: Generate a random number and query the database to ensure that there is no duplication; if there is no duplication, save the random number to the database as the object identifier; if there is a duplication, regenerate a random number as the object identifier. ② UUID (Universally Unique Identifier) scheme: Generate a 16-byte random string as the object identifier of the business object. ③ Database-based number segment scheme: Extract a number segment range from the database and generate an object identifier within the number segment range; for example, the number segment range is [1,1000], representing 1000 identifiers, and generate 1000 self-increment identifiers according to the number segment range as the object identifiers of 1000 business objects. ④ Twitter (snowflake algorithm) scheme: Generate object identifiers according to the identification algorithm.
[0004] Practice has found that among the above-mentioned object identifier generation schemes, the random number scheme, the UUID scheme, and the database-based scheme are highly dependent on the database and random algorithms. As the number of generated object identifiers increases, random collisions may occur, and the same object identifiers may be generated for different business objects, making it difficult to ensure the uniqueness of the object identifiers. The snowflake algorithm scheme may have a clock dialback problem, resulting in repeated object identifiers, and it is also difficult to ensure the uniqueness of the object identifier. It can be seen that the current schemes for generating object identifiers are difficult to ensure the uniqueness of object identifiers. Summary of the invention
[0005] The embodiments of the present application provide an identifier generation method, apparatus, computer equipment, storage medium, and program product, which can ensure the uniqueness of the object identifier generated for the business object.
[0006] On the one hand, an embodiment of the present application provides a method for generating an identifier, the method comprising:
[0007] Generate a first identifier for the target business object according to the identifier generation rule; the first identifier includes identifier generation information, and the first identifier uniquely identifies the target business object through the identifier generation information;
[0008] Encrypting the first identifier to obtain an encrypted identifier of the target business object;
[0009] The encrypted identifier is encoded to obtain a second identifier of the target business object; the encoding process is used to optimize the identifier attribute of the encrypted identifier;
[0010] The second identifier of the target business object is marked as the unique object identifier of the target business object.
[0011] Accordingly, an embodiment of the present application provides an identification generation device, the identification generation device comprising:
[0012] A generating unit, configured to generate a first identifier for a target business object according to an identifier generation rule; the first identifier includes identifier generation information, and the first identifier uniquely identifies the target business object through the identifier generation information;
[0013] A processing unit, configured to encrypt the first identifier to obtain an encrypted identifier of a target business object;
[0014] The processing unit is further used to encode the encrypted identifier to obtain a second identifier of the target business object; the encoding process is used to optimize the identifier attribute of the encrypted identifier;
[0015] The processing unit is further configured to mark the second identifier of the target business object as the unique object identifier of the target business object.
[0016] In one implementation, the identifier generation information includes: a target timestamp, a node number, and a target sequence number; the target timestamp is used to indicate the generation time of the first identifier; the node number is used to indicate the node device that generates the first identifier; the identifier generation rule supports the generation of multiple identifiers at the same timestamp, and the target sequence number is used to indicate the generation order of the first identifier among the multiple identifiers generated by the target timestamp;
[0017] The generating unit is used to generate the first identifier for the target business object according to the identifier generation rule, and is specifically used to perform the following steps:
[0018] Generate identifier generation information according to the identifier generation rule;
[0019] Generate a first random number for the target business object according to a random number generation rule;
[0020] The first random number is concatenated with the identifier generation information to obtain a first identifier.
[0021] In one implementation, the node device that generates the first identifier is represented as a target node device; the generating unit is used to generate the identifier generation information according to the identifier generation rule, specifically to perform the following steps:
[0022] If the current timestamp of the target node device does not overflow under the timestamp length, the current timestamp is determined as the target timestamp;
[0023] If the current timestamp is the same as the local timestamp recorded by the target node device, the local sequence number recorded by the target node device is updated to obtain an updated local sequence number;
[0024] If the updated local sequence number does not overflow under the sequence number length, the updated local sequence number is determined as the target sequence number;
[0025] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0026] In one implementation, the generating unit is further configured to perform the following steps:
[0027] If the current timestamp is different from the local timestamp recorded by the target node device, the local sequence number recorded by the target node device is reset to obtain a reset local sequence number;
[0028] Determine the reset local sequence number as the target sequence number;
[0029] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0030] In one implementation, the generating unit is further configured to perform the following steps:
[0031] If the current timestamp overflows under the timestamp length, the local version identifier recorded by the target node device is obtained; the local version identifier is used to indicate the version of the rule adopted by the target node device in the identification generation process, and the rule includes at least one of the following: identification generation rule, encryption rule adopted by encryption processing, and encoding rule adopted by encoding processing;
[0032] Resetting the local timestamp recorded by the target node device to obtain a reset local timestamp, and determining the reset local timestamp as the target timestamp;
[0033] Resetting the local sequence number recorded by the target node device to obtain a reset local sequence number, and determining the reset local sequence number as the target sequence number;
[0034] The local version identifier, target timestamp, node number and target sequence number are concatenated to obtain identifier generation information.
[0035] In one implementation, the generating unit is further configured to perform the following steps:
[0036] If the updated local sequence number overflows under the sequence number length, wait for the local timestamp to be updated from the current timestamp to the next timestamp of the current timestamp;
[0037] When the local timestamp is updated from the current timestamp to the next timestamp, the updated local sequence number is reset to obtain the reset local sequence number, and the reset local sequence number is determined as the target sequence number; and the next timestamp is determined as the target timestamp;
[0038] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0039] In one implementation, the identification attribute of the encrypted identification includes the identification length of the encrypted identification, the encoding process includes length reduction process; the optimization refers to reducing the identification length of the encrypted identification; the encoding process is associated with a coding set, and the coding set includes multiple coding characters; the processing unit is used to perform the encoding process on the encrypted identification, and when the second identification of the target business object is obtained, it is specifically used to execute the following steps:
[0040] Determine the encrypted identifier as the identifier to be reduced;
[0041] Determine the modulus and quotient between the identifier to be reduced and the size information of the code set; the size information refers to the number of coded characters included in the code set;
[0042] Get the coded character matching the pattern in the coded set;
[0043] The quotient is used to update the identification to be reduced. If the identification to be reduced meets the conditions for continued reduction, the modulus and quotient between the identification to be reduced and the scale information are continuously determined until the identification to be reduced does not meet the conditions for continued reduction.
[0044] When the identifier to be reduced does not meet the conditions for further reduction, the coded characters corresponding to each module are concatenated to obtain the second identifier of the target business object.
[0045] In one implementation, the processing unit is used to encode the encrypted identifier to obtain the second identifier of the target business object, and is specifically used to perform the following steps:
[0046] Encoding the encrypted identifier to obtain the encoded identifier of the target business object;
[0047] Obtaining an extended identifier corresponding to the first identifier, where the extended identifier is used to extend the identification capability of the first identifier;
[0048] The encoding identifier and the extension identifier are concatenated to obtain a second identifier of the target business object.
[0049] In one implementation, the extended identifier includes a random identifier, the random identifier is used to extend the anti-collision capability of the first identifier, and the random identifier includes one or more character bits; the encoding process is associated with a code set, and the code set includes multiple coded characters; the processing unit is used to obtain the extended identifier corresponding to the first identifier, and is specifically used to perform the following steps:
[0050] generating a random number generation range according to scale information of the code set, where the scale information refers to the number of code characters included in the code set;
[0051] Based on the random number generation range, generate a second random number for the target character position in the random identifier;
[0052] Determine the coded character in the coded set that matches the second random number as the character corresponding to the target character position;
[0053] The characters corresponding to each character position in the random identifier are concatenated to obtain a random identifier.
[0054] In one implementation, the node device that generates the first identifier is represented as the target node device; the extended identifier includes a version identifier, and the version identifier is used to extend the circulation time capability of the first identifier; the processing unit is used to obtain the extended identifier corresponding to the first identifier, specifically to perform the following steps:
[0055] Obtaining a local version identifier recorded by the target node device, where the local version identifier is generated based on the local version number recorded by the target node device, and the local version number is used to indicate the version of the rule used by the target node device in the identifier generation process, where the rule includes at least one of the following: an identifier generation rule, an encryption rule used in encryption processing, and an encoding rule used in encoding processing;
[0056] If the rule has not been upgraded, the local version identifier is determined as the version identifier;
[0057] If the rule is upgraded, the local version number is updated, and a version identifier is generated according to the updated local version number.
[0058] In one implementation, the encoding process is associated with a code set, which includes a plurality of coded characters; the extended identifier includes a check identifier, which is used to extend the check capability of the first identifier; and the processing unit is used to obtain the extended identifier corresponding to the first identifier, specifically to perform the following steps:
[0059] Determine verification information corresponding to the coding identifier based on a verification algorithm;
[0060] Determine conversion information according to the scale information of the code set and the number of character digits included in the check mark; the scale information refers to the number of coded characters included in the code set, and the number of character digits refers to the number of characters included in the check mark;
[0061] Convert the verification information according to the conversion information to obtain a conversion identifier of the verification information;
[0062] The conversion identifier is encoded to obtain a verification identifier.
[0063] In one implementation, the generating unit is further configured to perform the following steps:
[0064] receiving a target generation subtask, the target generation subtask being used to request generation of multiple unique object identifiers of multiple business objects for multiple business objects, the target business object being any one of the multiple business objects; the target generation subtask being any generation subtask obtained by dividing the identifier generation task;
[0065] Execute the target generation subtask to generate unique object identifiers of multiple business objects for the multiple business objects;
[0066] Among them, the target generation subtask is executed by any node device in the business system, and the business system divides the identifier generation task into multiple generation subtasks according to the identifier generation capability information of the business system; the identifier generation capability information is used to indicate the upper limit of the number of identifiers that each node device in the business system can generate per unit time; a node device in the business system is used to execute a generation subtask.
[0067] Accordingly, an embodiment of the present application provides a computer device, the computer device comprising:
[0068] a processor suitable for implementing a computer program;
[0069] A computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the above-mentioned identification generation method.
[0070] Accordingly, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is read and executed by a processor of a computer device, the computer device executes the above-mentioned identification generation method.
[0071] Accordingly, an embodiment of the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned identification generation method.
[0072] In the embodiment of the present application, the first identifier generated for the business object can be encrypted and encoded to obtain a second identifier, and the second identifier can be marked as the unique object identifier of the business object; the first identifier can include identifier generation information, and the identifier generation information is unique. The first identifier can uniquely identify the target business object through the identifier generation information, thereby ensuring the uniqueness of the object identifier generated for the business object. In addition, the security of the object identifier generated for the business object can be improved through encryption processing; and the identification attribute of the object identifier generated for the business object can be optimized through encoding processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0074] Figure 1 It is a schematic diagram of the architecture of a business system provided by an embodiment of the present application;
[0075] Figure 2 is a schematic diagram of a digital product activation scenario provided in an embodiment of the present application;
[0076] Figure 3 is a schematic diagram of a prize redemption scenario provided in an embodiment of the present application;
[0077] Figure 4 It is a scene diagram of an order principle scene provided in an embodiment of the present application;
[0078] Figure 5 This is a schematic diagram of a commodity anti-counterfeiting scenario provided by an embodiment of the present application;
[0079] Figure 6 It is a flowchart of a method for generating an identifier provided in an embodiment of the present application;
[0080] Figure 7 This is a schematic diagram of a generation process of identification generation information provided by an embodiment of the present application;
[0081] Figure 8 is a schematic diagram of an exemplary first identifier provided in an embodiment of the present application;
[0082] Fig. 9 is a schematic diagram of an exemplary encryption process provided in an embodiment of the present application;
[0083] Fig.10It is a schematic diagram of a coding process provided by an embodiment of the present application;
[0084] Fig.11 is a schematic diagram of an exemplary encoding processing result provided in an embodiment of the present application;
[0085] Fig.12 This is a schematic diagram of distributed scheduling of a tag generation task provided by an embodiment of the present application;
[0086] Fig.13 This is a schematic diagram of an execution flow of an identification generation task provided in an embodiment of the present application;
[0087] Fig.14 It is a flowchart of another identification generation method provided in an embodiment of the present application;
[0088] Fig.15 This is a schematic diagram of a random identifier generation process provided in an embodiment of the present application;
[0089] Fig.16 It is a schematic diagram of splicing a coded identifier and a random identifier provided in an embodiment of the present application;
[0090] Fig.17 This is a schematic diagram of a generation process of a version identifier provided in an embodiment of the present application;
[0091] Fig.18 It is a schematic diagram of splicing a coding identifier, a random identifier, and a version identifier provided in an embodiment of the present application;
[0092] Fig.19 This is a schematic diagram of a generation process of a verification mark provided in an embodiment of the present application;
[0093] Fig. 20 It is a schematic diagram of splicing a coding identifier, a random identifier, a version identifier, and a verification identifier provided in an embodiment of the present application;
[0094] Fig.21 This is a schematic diagram of a second identification generation process provided in an embodiment of the present application;
[0095] Fig. 22 This is another schematic diagram of a second identification generation process provided in an embodiment of the present application;
[0096] Fig.23 It is a structural schematic diagram of an identification generation device provided in an embodiment of the present application;
[0097] Fig.24 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0098] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0099] The embodiment of the present application relates to a unique object identifier of a business object. A unique object identifier is information used to uniquely identify a business object. By assigning a unique object identifier to each business object, each business object can have its own unique identification information. Based on this, the embodiment of the present application proposes an identifier generation method, which can generate an object identifier for a business object and can ensure that the object identifier generated for the business object is unique. The identifier generation method provided in the embodiment of the present application involves encryption and encoding of the identifier in the process of generating an object identifier. The encryption process can improve the security of the identifier, and the encoding process can optimize the identifier attributes. In addition, the identifier generation method provided in the embodiment of the present application can also add any one or more of a random identifier, a version identifier, and a verification identifier to the generated identifier; the random identifier can further improve the security of the identifier; the version identifier can extend the service life of the identifier; the verification identifier can provide verification information of the identifier, which can verify whether the identifier has been changed, destroyed or accidentally damaged during transmission or storage.
[0100] The identification generation method provided in the embodiment of the present application can be executed by a computer device, and the computer device can be any node device in the business system, and the node device can be used to generate an object identification. The business system is introduced below.
[0101] like Figure 1 As shown, the business system may include a scheduling device 101 and a plurality of node devices 102 (eg, Figure 1 The embodiment of the present application does not limit the communication connection method between the scheduling device 101 and the multiple node devices 102. The scheduling device 101 and the multiple node devices 102 can establish a direct communication connection through wired communication; or, the scheduling device 101 and the multiple node devices 102 can establish an indirect communication connection through wireless communication.
[0102] The scheduling device 101 may be a terminal or a server, and the node device 102 may be a terminal or a server. The terminal may include but is not limited to any of the following: a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, a smart home appliance, a smart vehicle terminal, and an aircraft. The server may be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, etc.
[0103] In a business system composed of a scheduling device 101 and multiple node devices 102: the scheduling device 101 can receive an identifier generation task, which can be used to request the generation of a unique object identifier for each of multiple business objects; the scheduling device 101 can divide the identifier generation task into multiple generation subtasks, and schedule multiple node devices 102 to perform multiple generation subtasks, and one node device 102 can perform one generation subtask. Any node device 102 can use the identifier generation method provided in the embodiment of the present application to generate a unique object identifier for any business object requested by the generation subtask; after the generation subtask is completed, the node device 102 can package the generated object identifier into an object identifier subset and return it to the scheduling device 101. The scheduling device 101 can package the object identifier subsets returned by each node device 102 into an object identifier set and return it to the publisher of the identifier generation task.
[0104] It can be seen that the business system is a distributed system composed of a scheduling device 101 and multiple node devices 102. The distributed system here can be understood as that the scheduling device 101 can dispatch the identification generation task to multiple node devices 102 for distributed execution, and multiple node devices 102 concurrently execute multiple generation subtasks, which can improve the execution efficiency of the identification generation task and improve the identification generation efficiency.
[0105] It can be understood that the business system described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided in the embodiment of the present application. It is known to those skilled in the art that with the evolution of the business system architecture and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.
[0106] The identification generation method provided in the embodiment of the present application can be applied to any scenario where a unique object identification needs to be generated for a business object. The following introduces the application scenarios of the identification generation method from two perspectives: the type of business object and the application of the unique object identification.
[0107] (1) From the perspective of business object types:
[0108] Business objects may include any of the following: items (e.g., tables, pencils, and books, etc.), digital products (e.g., software, applications, and electronic games, etc.), orders (e.g., takeout orders and shopping orders, etc.), express deliveries, and prizes (e.g., coupons, gift cards, and discount cards, etc.), etc. That is, the identifier generation method provided in the embodiment of the present application can be applied to the scenario of generating unique object identifiers for different types of business objects, for example, generating a unique object identifier for each item as a unique item identifier of the item, generating a unique object identifier for each order as a unique order number of the order, generating a unique object identifier for each express as the express delivery number of the express, and generating a unique object identifier for each prize as a redemption code of the prize, etc.
[0109] (2) From the perspective of unique object identification:
[0110] The application methods of the unique object identifier can be divided into two categories: the first application method is that the unique object identifier is directly associated with the business object, and the business object can be obtained or used by using the unique object identifier; the second application method is that the unique object identifier is associated with the object information of the business object, and the object information of the business object can be obtained by using the unique object identifier. Optionally, the embodiment of the present application does not limit the use of the unique object identifier, and the use of the unique object identifier may include: the first use method, directly using the unique object identifier, for example, directly inputting the unique object identifier; the second use method, the unique object identifier can be presented in the form of a carrier, and the carrier is a presentation form generated based on the unique object identifier, for example, the carrier can be a two-dimensional code (a two-dimensional code refers to a black and white graphic that records data symbol information distributed in a plane (two-dimensional direction) according to a certain rule with a certain specific geometric figure), a barcode or other image code, and the unique object identifier can be used by scanning the graphic code.
[0111] The application scenarios corresponding to the first type of application method may include, for example, digital product activation scenarios and prize redemption scenarios.
[0112] Digital product activation scenarios such as Figure 2As shown, the unique object identifier of a digital product (e.g., software, application, and electronic game, etc.) can be used as an activation code for the digital product, and the digital product can be activated and used by entering the activation code; the identifier generation method provided in the embodiment of the present application can provide a unique and secure activation code for the digital product activation scenario, ensuring the legitimacy and security of the digital product authorization.
[0113] Prize redemption scenarios such as Figure 3 As shown, the unique object identifier of the prize can be used as a redemption code for the prize, and the prize can be obtained by entering the redemption code. Figure 3 Taking the example of a prize being a coupon, the prize may also be a gift card, discount card, etc. The identification generation method provided in the embodiment of the present application can provide a unique and secure redemption code for the prize redemption scenario to prevent the abuse and forgery of the redemption code.
[0114] The application scenarios corresponding to the second type of application mode may include, for example, order management scenarios, express delivery management scenarios, product anti-counterfeiting scenarios, and product traceability scenarios.
[0115] Order management scenarios such as Figure 4 As shown, the unique object identifier of an order can be used as the unique order number of the order, and the unique order number is associated with the order information (for example, the order time, the ordered items, and the order notes, etc.), and the order information can be queried by entering the unique order number; the identification generation method provided in the embodiment of the present application can provide a unique and secure order number for the order management scenario, which is convenient for order management and order query. The express management scenario is similar to the order management scenario. The unique object identifier of the express can be used as the unique express delivery number of the express, and the unique express delivery number is associated with the express delivery information (for example, logistics information, delivery information, etc.), and the express delivery information can be queried by entering the unique express delivery number; the identification generation method provided in the embodiment of the present application can provide a unique and secure express delivery number for the express management scenario, ensuring the security and accuracy of express delivery query.
[0116] Product anti-counterfeiting scenarios such as Figure 5As shown, the unique object identifier of a commodity can be used as the anti-counterfeiting code of the commodity in the form of a two-dimensional code carrier. The anti-counterfeiting code is associated with the anti-counterfeiting information of the commodity, and the anti-counterfeiting information of the commodity can be obtained by scanning the anti-counterfeiting code; specifically, the identifier generation method provided in the embodiment of the present application can generate a unique object identifier for the commodity as an anti-counterfeiting code, and associate the anti-counterfeiting code with the anti-counterfeiting information of the commodity. The anti-counterfeiting code can also be presented on a graphic code carrier, and the anti-counterfeiting information of the commodity can be obtained by scanning the graphic code; the anti-counterfeiting requirements for cosmetics, bags and other commodities are extremely high, and a unique and secure anti-counterfeiting code can be provided for these commodities with high anti-counterfeiting requirements, thereby effectively preventing counterfeiting and imitation, and protecting the rights and interests of consumers and the interests of commodity manufacturers. The commodity traceability scenario is similar to the commodity anti-counterfeiting scenario. The unique object identifier of the commodity can be used as the traceability code of the commodity in the form of a QR code carrier. The traceability code is associated with the traceability information of the commodity (for example, the traceability information may include production date, origin, quality, etc.), and the traceability information of the commodity can be obtained by scanning the traceability code; specifically, the identification generation method provided in the embodiment of the present application can generate a unique object identifier for the commodity as a traceability code, and associate the traceability code with the traceability information of the commodity. The traceability code can also be presented in a graphic code carrier, and the traceability information of the commodity can be obtained by scanning the graphic code; fresh commodities and other commodities have high requirements for the traceability link. By providing a unique and secure traceability code for these commodities with high traceability link requirements, the complete traceability of the commodity traceability link can be achieved, and accurate and reliable traceability information can be provided.
[0117] The following is a detailed introduction to the identification generation method provided in the embodiment of the present application in conjunction with the accompanying drawings.
[0118] The present application embodiment provides an identification generation method, which includes: a first identification generation process, an encryption process, an encoding process, and a distributed scheduling method for identification generation tasks. The identification generation method can be executed by a computer device, which can be, for example, any node device in a business system (which can be represented as a target node device). Figure 6 As shown, the identification generation method may include but is not limited to the following steps S601 to S604:
[0119] S601, generating a first identifier for a target business object according to an identifier generation rule; the first identifier includes identifier generation information, and the first identifier uniquely identifies the target business object through the identifier generation information.
[0120] The first identifier generated for the target business object in the business system according to the identifier generation rule may include identifier generation information, and the first identifier may uniquely identify the target business object through the identifier generation information. Among them, the identifier generation information may include: a target timestamp, a node number, and a target sequence number; the target timestamp may be used to indicate the generation time of the first identifier; the node number may be used to indicate the node device that generates the first identifier; the identifier generation rule may support the generation of multiple identifiers at the same timestamp, and the target sequence number may be used to indicate the generation order of the first identifier among the multiple identifiers generated by the target timestamp. It can be seen that the identifier generation information obtained by combining the timestamp, the node number, and the sequence number is unique, and the identifier generation information generated for the target business node can uniquely identify the target business object, so that the first identifier containing the identifier generation information can uniquely identify the target business object.
[0121] The process of generating a first identifier for a target business object in a business system according to an identifier generation rule may include: generating identifier generation information according to the identifier generation rule; generating a first random number for the target business object according to a random number generation rule; and concatenating the first random number with the identifier generation information to obtain the first identifier. In the above process of generating the first identifier, a random number is added on the basis of the identifier generation information, and the random number can increase the disorder of the first identifier and further improve the security of the first identifier.
[0122] The process of generating the identifier generation information according to the identifier generation rule is as follows: Figure 7 As shown, it may include: obtaining the current timestamp of the target node device, judging whether the current timestamp overflows under the specified timestamp length, where the timestamp length refers to the number of character digits contained in the timestamp. In the case where the current timestamp of the target node device does not overflow under the timestamp length, it may be judged whether the current timestamp of the target node device is the same as the local timestamp recorded by the target node device. In the case where the current timestamp of the target node device is the same as the local timestamp recorded by the target node device, the local sequence number recorded by the target node device may be updated to obtain an updated local sequence number, and it may be judged whether the updated local sequence number overflows under the specified sequence number length, where the sequence number length refers to the number of character digits contained in the sequence number. In the case where the updated local sequence number does not overflow under the sequence number length, the updated local sequence number may be determined as the target sequence number. Then, the target timestamp, the node number and the target sequence number may be spliced to obtain the identification generation information, and the identification generation information may be spliced with the first random number to obtain the first identification, that is, the first random number, the target timestamp, the node number and the target sequence number are spliced to obtain the first identification.
[0123] If the current timestamp of the target node device does not overflow under the timestamp length, and the current timestamp is different from the local timestamp recorded by the target node device, the local sequence number recorded by the target node device can be reset to obtain the reset local sequence number, and the reset local sequence number can be determined as the target sequence number. Then, the target timestamp, node number and target sequence number can be spliced to obtain the identification generation information, and the identification generation information can be spliced with the first random number to obtain the first identification, that is, the first random number, target timestamp, node number and target sequence number are spliced to obtain the first identification.
[0124] In the case where the current timestamp of the target node device overflows under the timestamp length, the local version identifier recorded by the target node device can be obtained; the local version identifier can be used to indicate the version of the rule adopted by the target node device in the identification generation process, and the rule can include at least one of the following: identification generation rule, encryption rule adopted by encryption processing, and encoding rule adopted by encoding processing. The local timestamp recorded by the target node device can be reset to obtain the reset local timestamp, and the reset local timestamp can be determined as the target timestamp. For the sequence number, the local sequence number recorded by the target node device can be reset to obtain the reset local sequence number, and the reset local sequence number can be determined as the target sequence number. Then, the local version identifier, the target timestamp, the node number and the target sequence number can be spliced to obtain the identification generation information, and the identification generation information can be spliced with the first random number to obtain the first identification, that is, the first random number, the local version identifier, the target timestamp, the node number and the target sequence number are spliced to obtain the first identification.
[0125] In the case where the current timestamp of the target node device does not overflow under the timestamp length, and the current timestamp is the same as the local timestamp recorded by the target node device, and the updated local sequence number overflows under the sequence number length, you can wait for the local timestamp recorded by the target node device to be updated from the current timestamp to the next timestamp of the current timestamp. When the local timestamp is updated from the current timestamp to the next timestamp, the updated local sequence number can be reset to obtain the reset local sequence number, and the reset local sequence number is determined as the target sequence number, and the next timestamp is determined as the target timestamp. Then, the target timestamp, node number and target sequence number can be spliced to obtain identification generation information, and the identification generation information can be spliced with the first random number to obtain the first identification, that is, the first random number, target timestamp, node number and target sequence number are spliced to obtain the first identification.
[0126] In the process of generating identifier generation information according to the identifier generation rules, overflow is involved. The common concept of overflow is: the data stored inside the computer device is stored in binary form. If the number of bits of the stored data exceeds the limited number of bits, overflow will occur, that is, the value exceeds the maximum value that the data type can express. Combining the concept of overflow with the process of generating identifier generation information according to the identifier generation rules, the timestamp length refers to the number of character bits contained in the timestamp; the current timestamp does not overflow under the timestamp length means: the value corresponding to the current timestamp does not exceed the maximum value corresponding to the timestamp length; the current timestamp overflows under the timestamp length means: the value corresponding to the current timestamp exceeds the maximum value corresponding to the timestamp length; the maximum value corresponding to the timestamp length is determined according to the number of character bits contained in the timestamp. For example, when the characters in the timestamp are represented by binary characters and the number of character bits in the timestamp is 10, the maximum value corresponding to the timestamp is 11111111111. The sequence number length refers to the number of character bits contained in the sequence number; the updated local sequence number does not overflow under the sequence number length, which means that the updated local sequence number does not exceed the maximum sequence number corresponding to the sequence number length; the updated local sequence number overflows under the sequence number length, which means that the updated local sequence number exceeds the maximum sequence number corresponding to the sequence number length; similar to the timestamp length, the maximum sequence number corresponding to the sequence number length is determined based on the number of character bits contained in the sequence number.
[0127] The process of generating identification generation information according to the identification generation rules is analyzed as follows: First, when the current timestamp of the target node device does not overflow under the timestamp length, and the current timestamp is the same as the local timestamp recorded by the target node device, it can be explained that it is in the stage of generating serial numbers under the local timestamp, and it is necessary to determine whether the number of serial numbers generated under the local timestamp has reached the number of serial numbers supported by the same timestamp. Second, the local serial number can be updated in such a way that the updated local serial number is equal to the current local serial number plus 1. By adding 1 to the update, it can be ensured that the serial number can reflect both the generation order of the serial numbers under the current timestamp and the number of serial numbers generated in the current timestamp stage. Third, the local serial number is recorded in the local memory of the target node device. For the serial number generation stage of the same timestamp, the serial number recorded in the local memory can be continuously added by 1 in the local memory of the target node device. The calculation method is simple, which can improve the efficiency of serial number generation, thereby improving the efficiency of identification generation. Fourth, if the current timestamp of the target node device does not overflow under the timestamp length, and the current timestamp is different from the local timestamp recorded by the target node device, it can be said that the stage of generating serial numbers under the local timestamp has ended, and it is necessary to start the stage of generating serial numbers under the current time period. Therefore, the local serial number recorded by the target node device can be reset. Fifth, the number of characters in the timestamp determines the service life of the first identifier. During the service life of the first identifier, the first identifier will not be repeated. If the current timestamp of the target node device overflows under the timestamp length, the given number of timestamp characters can no longer express the current timestamp. If the number of characters in the timestamp is not extended, repeated first identifiers may appear. Therefore, by adding a version identifier and resetting the timestamp, it is equivalent to increasing the number of characters contained in the timestamp, which can extend the service life of the first identifier.
[0128] For example, if Figure 8 As shown, the first identifier can be represented by a 64-bit binary number. The 64-bit binary number is an 8-byte long integer number on the computer device. Using a long integer number can be convenient for handling the unique identification problem. Just follow the following identifier generation rules to simply and efficiently implement the local memory calculation of the target node device. The identifier generation rule can be, for example, that the entire 64-bit binary number is divided into 4 parts:
[0129] The 6-bit random number can be used to increase the disorder of the first identification and improve security. The 42-bit timestamp can be used to record the timestamp of the generation of the first identification in milliseconds. The 42-bit timestamp can make the first identification valid for up to 2 42milliseconds (approximately equal to 139 years), so that the first identification can be guaranteed not to be repeated in 139 years. The 6-bit node number can be used to record the node device that generates the first identification; the number of characters contained in the node number is related to the number of node devices deployed in the business system. For example, when the business system deploys 64=2 6 When there are 64 node devices in the business system, a 6-bit binary node number can fully express the 64 node devices included in the business system. The business system deploys multiple node devices to generate distributed identifiers to achieve distributed high-performance computing. The 10-bit serial number can be used to indicate the number of serial numbers that can be generated in the same timestamp, as well as the generation order of identifiers in the same timestamp. By calculation, a single node device can generate 2 10 = 1024 sequence numbers, that is, a single node device can generate 2 10 = 1024 unique object identifiers. If the timestamp is in milliseconds, a single node device can generate 1024 serial numbers in the same millisecond, that is, a single node device can generate 1.024 million unique object identifiers per second, and the 64 node devices in the business system can generate 65.536 million unique object identifiers per second.
[0130] The first random number, the target timestamp, the node number, and the target sequence number are concatenated to obtain the first identifier, as shown in the following formula 1:
[0131] First identifier = first random number << 58 | timestamp << 16 | node number << 10 | sequence number (Formula 1)
[0132] In the above formula 1, the symbol "<<" indicates a left shift operation, "<<58" indicates a left shift of 58 bits, and the symbol "|" indicates an OR operation. It should be noted that Figure 8 In the first identification shown, the splicing order of the random number, timestamp, node number and serial number is only used as an example. The embodiment of the present application does not limit the splicing order of the random number, timestamp, node number and serial number. For example, it can be as follows Figure 8 As shown, the random number, the timestamp, the node number and the serial number are concatenated in order to obtain the first identifier. For example, the random number, the node number, the serial number and the timestamp can be concatenated in order to obtain the first identifier.
[0133] S602: Encrypt the first identifier to obtain an encrypted identifier of the target business object.
[0134] The encryption process may be implemented according to an encryption rule, which specifies an encryption function and an encryption key. In other words, the first identifier may be encrypted based on the encryption function and the encryption key to obtain an encrypted identifier of the target business object. Fig. 9As shown, the encryption process can achieve the purpose of obfuscation and disorder, making it impossible to directly see the pattern of the first identification, thereby improving the security of the first identification.
[0135] The encryption process is shown in the following formula 2:
[0136] Encryption ID = XXTEA (first ID, encryption key) (Formula 2)
[0137] In the above formula 2, XXTEA (an encryption function) represents an exemplary encryption function, and the input parameters of the encryption function are the first identifier and the encryption key. It should be noted that the encryption function is XXTEA for example only, and the embodiments of the present application do not limit the encryption function, and other encryption functions that can encrypt identifiers composed of binary numbers can be applied to the embodiments of the present application.
[0138] S603, encode the encrypted identifier to obtain a second identifier of the target business object; the encoding process is used to optimize the identifier attribute of the encrypted identifier.
[0139] The encoding process can be used to optimize the identification attribute of the encrypted identification. The identification attribute of the encrypted identification can include the identification length of the encrypted identification. The encoding process can include length reduction processing. Optimization can refer to reducing the identification length of the encrypted identification. That is, the encoding process can be used to reduce the identification length of the encrypted identification. If the identification length is too long, it will be difficult for the identification to adapt to the restriction requirements of the business object packaging size. The advantage of reducing the identification length is that the length of the encrypted identification can be optimized so that the identification can better adapt to the restriction requirements of the business object packaging size.
[0140] The encoding process can be implemented by using encoding rules, and the encoding rules specify the encoding algorithm and the encoding set used for encoding. The embodiment of the present application is explained by taking the encoding algorithm as the BASE62 algorithm as an example. The encoding set corresponding to the BASE62 algorithm includes 62 encoding characters, and the 62 encoding characters include 10 numbers, 26 lowercase letters and 26 uppercase letters, that is, the encoding characters included in the encoding set corresponding to the BASE62 algorithm are "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY Z"; the BASE62 algorithm can convert the binary encryption identifier into a 62-base identifier represented by the encoding characters in the encoding set to achieve lossless compression of the identifier. Since the encoding process is lossless, the length of the identifier can be reduced without affecting the integrity and security of the identifier.
[0141] The encoding processing logic of the encoding algorithm can be understood as the base conversion logic, such as Fig.10As shown, the process of encoding the encrypted identifier to obtain the second identifier of the target business object may include: determining the encrypted identifier as the identifier to be reduced; obtaining the scale information of the code set, the scale information refers to the number of coded characters included in the code set; determining the modulus and quotient between the identifier to be reduced and the scale information of the code set; obtaining the coded characters matching the modulus in the code set; using the quotient to update the identifier to be reduced, if the identifier to be reduced meets the condition for continued reduction, then continue to determine the modulus and quotient between the identifier to be reduced and the scale information until the identifier to be reduced does not meet the condition for continued reduction; when the identifier to be reduced does not meet the condition for continued reduction, the coded characters corresponding to each modulus are spliced to obtain the second identifier of the target business object.
[0142] During the encoding process, it should be noted that the identification to be reduced meets the conditions for continued reduction, which means that the value represented by the identification to be reduced is not 0, and the identification to be reduced does not meet the conditions for continued reduction, which means that the value represented by the identification to be reduced is 0. It should also be noted that each coded character in the encoding set has its own number, and the coded character that matches the modulus is the coded character corresponding to the number that matches the modulus. Taking the encoding algorithm used in the encoding process as the BASE62 algorithm as an example, the encoding set contains 62 coded characters, and the 62 coded characters can be numbered with 62 integers in the range [0, 61]. The modulus between the identification to be reduced and the scale information is also a value in the range [0, 61]. The number that matches the modulus is actually the number equal to the modulus. For example, when the modulus is 23, the coded character that matches the modulus is the coded character corresponding to the number 23 in the encoding set.
[0143] An example of encoding processing under the BASE62 algorithm is as follows Fig.11 As shown, the 64-bit binary encryption identifier is converted into an 11-bit 62-bit identifier, and the identifier length is significantly reduced, achieving lossless compression of the identifier. Since the encoding process is lossless, the identifier length can be reduced without affecting the integrity and security of the identifier. In a specific implementation, the encoding process can be directly implemented by calling the encoding algorithm, as shown in the following formula 3:
[0144] Second identifier = BASE62 (encryption identifier, number of characters in the second identifier) (Formula 3)
[0145] In the above formula 3, BASE62 represents the encoding algorithm, and the input parameters of the encoding algorithm are the number of character bits contained in the encryption identifier and the second identifier. The number of character bits contained in the second identifier can be determined based on the number of character bits contained in the first identifier or the encryption identifier and the encoding algorithm, and the number of character bits contained in the first identifier and the encryption identifier are equal; for example, for the encoding algorithm BASE62, the number of character bits contained in the first identifier and the encryption identifier is 64 bits, and 64-bit binary characters require 11 62-bit characters to represent, then the number of character bits contained in the second identifier is 11 bits. It should be noted that the encoding algorithm BASE62 is only used for example, and the embodiments of the present application do not limit the encoding algorithm. Other encoding algorithms that can convert the identifier composed of binary digits can be applied to the embodiments of the present application, for example, the encoding algorithm BASE64 (the encoding set corresponding to the encoding algorithm BASE64 contains 64 encoding characters).
[0146] The content of step S603 above introduces that the encrypted identifier can be directly encoded to obtain the second identifier. Optionally, the identifier obtained by the encoding process can be concatenated with the extended identifier to finally obtain the second identifier. Specifically, the encrypted identifier can be encoded to obtain the encoded identifier of the target business object; the extended identifier corresponding to the first identifier can be obtained, and the extended identifier can be used to expand the identification capability of the first identifier; the encoded identifier and the extended identifier are concatenated to obtain the second identifier of the target business object.
[0147] Among them, the process of encoding the encrypted identifier to obtain the encoded identifier of the target business object is the same as the process of encoding the encrypted identifier to obtain the second identifier, which will not be repeated here. The extended identifier may include any of the following: a random identifier, a version identifier, and a verification identifier; the random identifier can be used to extend the anti-collision capability of the first identifier, and the anti-collision capability refers to the ability to avoid generating the same object identifier for different business objects. By adding a random identifier, the security and uniqueness of the identifier can be further improved; the version identifier can be used to extend the circulation time capability of the first identifier, and the circulation time capability specifically refers to the identifier life span, that is, the identifier life span can be extended by the version identifier; the verification identifier can be used to extend the verification capability of the first identifier, and the verification capability means that the verification identifier can be used to verify the correctness of the first identifier, and verify whether the first identifier is changed, destroyed or accidentally damaged during the transmission or storage process. By adding a verification identifier, the integrity and compliance of the identifier can be improved, and the recognition accuracy of the identifier can be improved.
[0148] S604: Mark the second identifier of the target business object as the unique object identifier of the target business object.
[0149] After obtaining the second identifier of the target business object, the second identifier of the target business object can be marked as the unique object identifier of the target business object in the business system. Specifically, the unique object identifier of the target business object can be associated with the target business object to obtain or use the target business object through the unique object identifier of the target business object. Alternatively, the unique object identifier of the target business object can be associated with the object information of the target business object to obtain the object information of the target business object through the unique object identifier of the target business object.
[0150] It should be noted that the above steps S601-S604 introduce the process of generating a unique object identifier for a target business object by a target node device in a business system, and the process of generating a unique object identifier for a target business object is performed when executing a target generation subtask scheduled by a scheduling device. Specifically, the target node device can receive a target generation subtask, which can be used to request the generation of multiple unique object identifiers for multiple business objects, where the target business object is any one of the multiple business objects; the target node device can respond to the target generation subtask and generate multiple unique object identifiers for multiple business objects.
[0151] The target generation subtask is any generation subtask obtained by dividing the identity generation task. After receiving the target generation subtask, the business system divides the identity generation task into multiple generation subtasks according to the identity generation capability information of the business system. The identity generation task is specifically divided by the scheduling device in the business system; then, the scheduling device in the business system can schedule the multiple generation subtasks obtained by the division to be executed in a distributed manner by multiple node devices in the business system. A node device in the business system can be used to execute a generation subtask. The identity generation capability information can be used to indicate the upper limit of the number of identifiers that each node device in the business system can generate per unit time. The number of identifiers generated by each generation subtask request is less than or equal to the upper limit of the number of identifiers.
[0152] Taking the first identifier of each node device in the business system as a 64-bit binary number (including a 6-bit random number, a 42-bit timestamp, a 6-bit node number and a 10-bit serial number), and the timestamp unit is milliseconds, as an example, a single node device can generate 1024 unique object identifiers per millisecond, and 1.024 million unique object identifiers per second, and 1 million can be used as identifier generation capability information, that is, the upper limit of the number of identifiers that each node device in the business system can generate per unit time is 1 million. Fig.12As shown, the key to distributed generation of identifiers is to set up multiple node devices, each of which can generate 1 million unique object identifiers per second; when the scheduling device in the business system receives an identifier generation task with a large number of identifiers requested to be generated, for example, the identifier generation task requests to generate 3 million unique object identifiers, the task can be divided into 1 million granularities, and the identifier generation task is divided into 3 generation subtasks, each of which requests to generate 1 million unique object identifiers; 3 node devices can be scheduled to execute 3 generation subtasks respectively, so that the identifier generation task with a requested number of 3 million identifiers can be completed within 1 second, achieving an identifier generation rate of 1 million per second for a single node device. In addition, when the number of characters contained in the node number is 6, the business system can support a maximum of 2 node devices to be deployed 6 =64. If all 64 node devices are used to generate identifiers, the identifier generation efficiency can reach 64 million per second, meeting the high performance requirements.
[0153] like Fig.13 As shown, the scheduling device in the business system schedules the multiple node devices in the business system to execute the multiple generated subtasks in a distributed manner. After the multiple node devices execute the generated subtasks and obtain the corresponding unique object identifiers, each node device can package the generated unique object identifiers into an object identifier subset and send it to the scheduling device. The scheduling device can merge the object identifier subsets sent by each node device into an object identifier set, and use the object identifier set as the execution result of the identifier generation task.
[0154] In an embodiment of the present application, the first identifier generated for the business object can be encrypted and encoded to obtain a second identifier, and the second identifier can be marked as a unique object identifier of the business object; the first identifier may include a random number, a timestamp, a node number, and a serial number. Through the combination of the random number, the timestamp, the node number, and the serial number, it can be ensured that the first identifier is unique, thereby ensuring the uniqueness of the object identifier generated for the business object. In addition, the random number in the first identifier can increase the disorder of the identifier and improve the security of the identifier. The timestamp in the first identifier can ensure that the first identifier is not repeated over a long period of time, ensuring that the identifier has a long service life. In addition, by dividing the identifier generation task into multiple generation subtasks, and having multiple node devices execute the generation subtasks in a distributed manner, the efficiency of identifier generation can be improved.
[0155] The present application embodiment provides an identification generation method, which includes: a random identification generation method, a version identification generation method, and a verification identification generation method. The identification generation method can be executed by a computer device, which can be, for example, any node device in a business system (which can be represented as a target node device). Fig.14 As shown, the identification generation method may include but is not limited to the following steps S1401 to S1406:
[0156] S1401, generate a first identifier for a target business object according to an identifier generation rule; the first identifier includes identifier generation information, and the first identifier uniquely identifies the target business object through the identifier generation information.
[0157] In the embodiment of the present application, the execution process of step S1401 is the same as that of the above Figure 6 The execution process of step S601 in the embodiment shown is the same, and the details can be found in the above Figure 6 The description of step S601 in the illustrated embodiment will not be repeated here.
[0158] S1402: Encrypt the first identifier to obtain an encrypted identifier of the target business object.
[0159] In the embodiment of the present application, the execution process of step S1402 is the same as the above Figure 6 The execution process of step S602 in the illustrated embodiment is the same, and the details can be found in the above Figure 6 The description of step S602 in the illustrated embodiment will not be repeated here.
[0160] S1403, encode the encrypted identifier to obtain the encoded identifier of the target business object; the encoding process is used to optimize the identifier attribute of the encrypted identifier.
[0161] In the embodiment of the present application, the process of encoding the encrypted identifier to obtain the encoded identifier of the target business object is the same as the above Figure 6 In step S603 of the embodiment shown, the process of encoding the encrypted identifier to obtain the second identifier of the target business object is the same, and the details can be seen in the above Figure 6 The description of step S603 of the illustrated embodiment will not be repeated here.
[0162] The number of character digits contained in the coding identifier can be determined based on the number of character digits contained in the first identifier or the encryption identifier and the coding algorithm, and the number of character digits contained in the first identifier and the encryption identifier are equal. For example, if the number of character digits contained in the first identifier and the encryption identifier is 64 bits, and the coding algorithm defined by the coding rule used in the coding process is BASE62, a 64-bit binary character requires 11 62-bit characters to represent it, and the number of character digits contained in the coding identifier is 11 bits.
[0163] S1404: Obtain an extended identifier corresponding to the first identifier, where the extended identifier is used to extend the identification capability of the first identifier.
[0164] The extension identifier may include at least one of a random identifier, a version identifier, and a verification identifier. In order to ensure the consistency between the extension identifier and the encoding identifier, the extension identifier may be generated using encoding characters in the encoding set. The following is a detailed introduction to the generation methods of three extension identifiers:
[0165] (1) Random identification:
[0166] The random identifier may include one or more character positions, and the generation process of the random identifier may include: generating a random number generation range based on the scale information of the coding set, the scale information refers to the number of coded characters included in the coding set; based on the random number generation range, generating a second random number for the target character position in the random identifier, the second random number is within the random number generation range; determining the coded character in the coding set that matches the second random number as the character corresponding to the target character position; and splicing the characters corresponding to each character position in the random identifier to obtain the random identifier.
[0167] In detail, Fig.15 As shown, taking BASE62 as an example, the number of coded characters included in the code set is 62, and the random number generation range can be determined to be [0, 61]. For any character position in the random identifier, a random function can be called (for example, the random function can be Random (a random function)) to generate a random integer in the random number generation range [0, 61] to obtain a second random number. Each coded character in the code set corresponds to its own number, and the coded character matching the second random number is the coded character corresponding to the number matching the second random number; the 62 coded characters in the code set can be numbered using 62 integers in the range [0, 61], and the number matching the second random number is actually the same as the second random number. The coded character matching the second random number in the code set is determined as the character corresponding to the current character position. Then, it can be determined whether the current random bit is the last random bit in the random identifier, that is, whether it is necessary to generate the next character in the random identifier; if it is the last random bit, it is not necessary to generate the next character in the random identifier, and the characters of each character bit can be concatenated to obtain the random identifier; if it is not the last random bit, it is necessary to generate the next character in the random identifier, and the random function can be called to generate a second random number for the next character bit, and determine the coded character matching the second random number as the character of the next character bit.
[0168] The above is an introduction to the generation process of the random identifier. In the specific implementation, the random identifier can be directly implemented by calling the encoding algorithm, as shown in the following formula 4:
[0169] Random ID = BASE62 (Random (0, 61), Y) (Formula 4)
[0170] In the above formula 4, BASE62 represents an encoding algorithm, the input parameters of the encoding algorithm are Random(0, 61) and Y, Random(0, 61) represents generating a second random number within the random number generation range [0, 61], and Y represents the number of characters contained in the random identifier.
[0171] like Fig.16 As shown, when the extended identifier includes a random identifier, the coding identifier and the random identifier of Y bits can be spliced to obtain a second identifier. Adding a random identifier to the coding identifier is to further improve the security of the coding identifier. Taking the coding algorithm as BASE62 as an example, when the first identifier is a 64-bit binary identifier, the coding identifier is an 11-bit 62-bit identifier. Through theoretical calculation, the size of the number space represented by the coding identifier is 62^11, which is already a very large security number, sufficient to cope with most security requirements. However, in some special scenarios, in order to further improve the security of the identifier, the embodiment of the present application can support splicing random identifiers for coding identifiers, and for each character bit added to the coding identifier, the size of the number space represented by the coding identifier is expanded by 62 times. In actual application scenarios, according to the requested number of identifiers and probabilistic calculations, the number of character bits contained in the added random identifier can be reasonably selected, thereby reducing the possibility of malicious attacks. By expanding the number space represented by the identifier, the time and computing resources required by the attacker when trying to crack the identifier are greatly increased, thereby improving the security of the identifier.
[0172] (2) Version identification:
[0173] The generation process of version identification is as follows Fig.17 As shown, it may include: obtaining a local version identifier recorded by the target node device, the local version identifier may be generated based on the local version number recorded by the target node device, the local version number is used to indicate the version of the rule adopted by the target node device in the identifier generation process, the rule includes at least one of the following: identifier generation rules, encryption rules adopted for encryption processing, and encoding rules adopted for encoding processing; if the rule has not been upgraded, the local version identifier may be determined as the version identifier; if the rule has been upgraded, the local version number may be updated, and the version identifier may be generated based on the updated local version number.
[0174] In the generation process of the above version identification, it should be noted that the local version identification can be obtained by encoding the local version number, and the encoding rules used in the encoding process are the same as the encoding rules used in the encoding process of the encryption identification. The process of encoding the local version number is the same as the process of encoding the encryption identification. For details, please refer to the process of encoding the encryption identification, which will not be repeated here. The version identification can be obtained by encoding the updated local version number, and the encoding rules used in the encoding process are the same as the encoding rules used in the encoding process of the encryption identification. The process of encoding the updated local version number is the same as the process of encoding the encryption identification. For details, please refer to the process of encoding the encryption identification, which will not be repeated here. It should also be noted that there is a corresponding relationship between different version numbers and different versions of the rules. The local version number is updated, specifically using the version number corresponding to the upgraded version of the rule, and the local version number is updated to obtain the updated version number, which can be understood as using the version number corresponding to the upgraded version of the rule as the updated local version number.
[0175] The above is an introduction to the generation process of the version identifier. In the specific implementation, if the rule is upgraded, the version identifier can be directly called by the encoding algorithm, as shown in the following formula 5:
[0176] Version ID = BASE62 (updated local version number, X) (Formula 5)
[0177] In the above formula 5, BASE62 represents an encoding algorithm, and the input parameters of the encoding algorithm are the updated local version number and X, where X represents the number of characters included in the version identifier.
[0178] like Fig.18 As shown, when the extended identifier includes a random identifier and a version identifier, the encoding identifier, the Y-bit random identifier and the X-bit version identifier may be concatenated to obtain a second identifier.
[0179] In summary, the version identifier is related to the rule version, and the version identifier is also related to the validity period of the identifier (see Figure 6 In the illustrated embodiment, step S601 describes that, in the case where the current timestamp of the target node device overflows under the timestamp length, the life span of the identifier can be extended by adding a version identifier and resetting the timestamp). Taking BASE62 as an example, in the process of adding a version identifier to the encoding identifier, for each additional character position in the version identifier, the number of rule versions that support upgrades can be expanded by 62 times, and the life span of the identifier can be extended by 62 times. In actual usage scenarios, the number of characters in the version identifier can be reasonably selected from aspects such as the rule version upgrade requirements and the identifier life span.
[0180] Among them, for version upgrade requirements, the encryption rules stipulate encryption keys. In actual applications, encryption keys may need to be updated regularly to maintain system security. By adding version identifiers, encryption keys can be easily managed and updated to ensure that the unique identifier of each version is encrypted using the corresponding encryption key; with the upgrade and optimization of the system, the identifier generation rules may need to be adjusted. By adding version identifiers, it can be ensured that the identifier generation rules of the new version remain compatible with the identifier generation rules of the old version, thereby avoiding the problem of unique object identifier conflicts caused by the version upgrade of the identifier generation rules. For the identifier lifespan, when the timestamp in the first identifier contains a 42-bit binary value, the identifier lifespan is 139 years, which is already a very long lifespan, sufficient to meet most market circulation needs. Even if the validity period expires, the identifier lifespan can be extended by adding a version identifier and resetting the timestamp, so that it can continue to be used.
[0181] (3) Verification mark:
[0182] The generation process of the verification mark is as follows Fig.19 As shown, it may include: determining the verification information corresponding to the coding identifier based on the verification algorithm; determining the conversion information according to the scale information of the coding set and the number of character bits contained in the verification identifier, the scale information refers to the number of coding characters included in the coding set, and the number of character bits refers to the number of characters contained in the verification identifier; converting the verification information according to the conversion information to obtain the conversion identifier of the verification information; encoding the conversion identifier to obtain the verification identifier.
[0183] In the process of generating the above-mentioned verification mark, it should be noted that the embodiment of the present application does not limit the verification algorithm. For example, the verification algorithm can be a CRC32 (Cyclic Redundancy Check) algorithm. The CRC32 algorithm can be called to perform cyclic redundancy calculation on the coding mark to obtain a checksum of a fixed length, and the checksum is the verification information corresponding to the coding mark; when the random mark and version mark have been added to the coding mark, the CRC32 algorithm can be called to perform cyclic redundancy calculation on the coding mark, the random mark and the version mark to obtain a checksum of a fixed length, and the checksum is the verification information corresponding to the coding mark. The conversion information is specifically the result of exponential operation using the scale information as the base and the number of character bits contained in the verification mark as the exponent. Converting the verification information according to the conversion information specifically refers to taking the verification information modulo the conversion information and calculating the modulus between the verification information and the conversion information. The process of encoding the conversion mark is the same as the process of encoding the encryption mark. Specifically, the process of encoding the encryption mark can be repeated here.
[0184] The generation process of the verification mark can be seen in the following formula 6:
[0185] Checksum = BASE62
[0186] (CRC32 (version identifier, encoding identifier, random identifier) % conversion information, Z) (Formula 6)
[0187] In the above formula 6, BASE62 represents the encoding algorithm, and the input parameters of the encoding algorithm are CRC32 (version identifier, encoding identifier, random identifier) % conversion information and Z. Among them, CRC32 (version identifier, encoding identifier, random identifier) represents the check information, and CRC32 (version identifier, encoding identifier, random identifier) % conversion information represents the modulus between the check information and the conversion information. Z represents the number of digits of the characters contained in the check identifier.
[0188] like Fig. 20 As shown, when the extended identifier includes a random identifier, a version identifier and a check identifier, the coding identifier, the random identifier of Y bits, the version identifier of X bits and the check identifier of Z bits can be spliced to obtain a second identifier. For the check identifier, a cyclic redundancy check is performed on the coding identifier (or the coding identifier, the random identifier and the version identifier) through a check algorithm, and a checksum of a fixed length is returned. The checksum generated is unique to the input data, which makes the check identifier suitable for verifying whether the identifier is changed, destroyed or accidentally damaged during transmission or storage. Finally, according to the number of characters contained in the required check identifier, a specific check identifier is obtained through a modulo algorithm. This check identifier can be added to the end of the string of the coding identifier so that it can be checked during decoding and verification, and the check capability of the extended identifier is extended.
[0189] S1405: Concatenate the encoding identifier and the extension identifier to obtain a second identifier of the target business object.
[0190] After the encoding process obtains the encoding identifier and the extension identifier, the encoding identifier and the extension identifier can be spliced to obtain the second identifier of the target business object. This application does not limit the splicing order between the encoding identifier and the extension identifier. Fig.16 , Fig.18 as well as Fig. 20 The concatenation order between the coding identifier and the extension identifier is only used as an example. For example, when the extension identifier includes a random identifier, a version identifier, and a verification identifier, the concatenation order between the coding identifier and the random identifier, the version identifier, and the verification identifier can be as follows: Fig. 20 As shown in the splicing order; for example, the splicing order between the coding identifier and the random identifier, the version identifier and the verification identifier can be the coding identifier, the version identifier, the verification identifier and the random identifier.
[0191] In summary, when the extended identifier includes a random identifier, a version identifier, and a verification identifier, the generation process of the second identifier of the target business object is as follows: Fig.21 and Fig. 22 As shown: a first identifier is generated according to an identifier generation rule; the first identifier is securely encrypted to obtain an encrypted identifier; the encrypted identifier is encoded to obtain an encoded identifier; a random identifier, a version identifier and a check identifier are added to the encoded identifier to obtain a second identifier, the second identifier = X-bit version identifier + encoding identifier + Y-bit random identifier + Z-bit check identifier.
[0192] S1406: Mark the second identifier of the target business object as the unique object identifier of the target business object.
[0193] In the embodiment of the present application, the execution process of step S1406 is the same as that of the above Figure 6 The execution process of step S604 in the embodiment shown is the same, and the details can be found in the above Figure 6 The description of step S604 in the illustrated embodiment will not be repeated here.
[0194] In an embodiment of the present application, the first identifier generated for the business object can be encrypted and encoded to obtain a second identifier, and the second identifier can be marked as a unique object identifier of the business object; the first identifier may include a random number, a timestamp, a node number and a sequence number. Through the combination of the random number, the timestamp, the node number and the sequence number, it can be ensured that the first identifier is unique, thereby ensuring the uniqueness of the object identifier generated for the business object. By encrypting and adding a random identifier, the security of the identifier can be improved. By encoding, the identifier length can be optimized to meet the size limit requirements of the identifier in the business object. By timestamps and added version identifiers, it can be ensured that the identifier has a long service life and improves the practicality of the identifier. By adding a verification identifier, the integrity and compliance of the identifier can be guaranteed, and the recognition accuracy of the identifier can be improved. By using the local memory of the target node device for calculation, for example, calculating the local timestamp, local sequence number, and local version number recorded in the local memory, the efficiency of identifier generation can be improved.
[0195] The following further analyzes the identification generation method proposed in the embodiment of the present application in combination with the collision probability and the collision cost.
[0196] (1) Collision probability:
[0197] The collision probability refers to the probability that a maliciously forged identifier is the same as the object identifier generated by the identifier generation method provided in the embodiment of the present application. The calculation formula of the collision probability is shown in the following formula 7:
[0198] Collision probability = number of objects / (size information of the encoding set ^ number of character bits of the object identifier) (Formula 7)
[0199] In the above formula 7, the number of objects refers to the number of business objects requesting to generate object identifiers; the size information of the code set refers to the number of coded characters contained in the code set. Taking the BASE62 coding algorithm as an example, the size information of the code set is 62. The number of character bits of the object identifier refers to the number of characters contained in the object identifier. Taking the case where the object identifier includes a coded identifier (11 bits) and a random identifier, and the number of objects is 100 million, the collision probability varies with the number of character bits of the random identifier as shown in Table 1 below:
[0200] Table 1
[0201]
[0202] As can be seen from Table 1 above, when the number of characters in the coded identifier is fixed, the more characters in the random identifier and the more characters in the object identifier, the smaller the collision probability and the higher the security of the identifier. In other words, if there is a high requirement for the security of the identifier, the number of characters in the random identifier can be increased to improve security.
[0203] (2) Collision cost:
[0204] The collision cost refers to the cost of maliciously forging an object identifier that is the same as the object identifier generated by the identifier generation method provided in the embodiment of the present application. The calculation formula of the collision cost is shown in the following formula 8:
[0205] Collision cost = 1 / collision probability / collision rate (Formula 8)
[0206] In the above formula 8, the collision rate refers to the rate at which an object identifier is queried and verified, and is also the rate at which a general server can withstand object identifier query verification. Due to the special scenario of object identification, once the object identifier is queried, the query times will be recorded, and the authenticity can be verified based on the query times of the object identifier. Therefore, the purpose of malicious forgery is generally to maliciously damage and dirty the query times, which will affect the normal use of the object identifier. Taking the object identifier including the coded identifier (11 bits) and the random identifier, the number of objects is 100 million, and the collision rate is 1000 as an example, the collision cost varies with the number of character bits of the random identifier as shown in Table 2 below:
[0207] Table 2
[0208] Collision Probability Collision rate The calculation process of collision cost Calculation results of collision cost 10^8 / 62^11 1000 1 / (10^8 / 62^11) / 1000 17 years 10^8 / 62^12 1000 1 / (10^8 / 62^12) / 1000 1023 10^8 / 62^13 1000 1 / (10^8 / 62^13) / 1000 63429 10^8 / 62^14 1000 1 / (10^8 / 62^14) / 1000 3932575 10^8 / 62^15 1000 1 / (10^8 / 62^15) / 1000 243819668
[0209] As can be seen from Table 2 above, when the length of the coded identifier is 11 bits, the length of the random identifier is 0 bits, the number of objects is 100 million, and the collision rate is 1000 per second, it takes 17 years to collide with an object identifier, which is already a very safe data. When the number of characters in the coded identifier is fixed, the more characters in the random identifier and the more characters in the object identifier, the smaller the collision probability, the higher the collision cost, and the higher the security of the identifier.
[0210] The method of the embodiment of the present application is described in detail above. In order to facilitate better implementation of the above scheme of the embodiment of the present application, the device of the embodiment of the present application is provided below accordingly.
[0211] See also Fig.23 , Fig.23 It is a structural diagram of an identification generation device provided in an embodiment of the present application. The identification generation device can be set in a computer device provided in an embodiment of the present application. The computer device can be any node device in the business system (can be represented as a target node device). Fig.23 The identification generating device shown may be a computer program running in a computer device, and the identification generating device may be used to execute Figure 6 or Fig.14 Some or all of the steps in the method embodiment shown. Fig.23 , the identification generating device may include the following units:
[0212] A generating unit 2301 is used to generate a first identifier for a target business object according to an identifier generation rule; the first identifier includes identifier generation information, and the first identifier uniquely identifies the target business object through the identifier generation information;
[0213] The processing unit 2302 is used to encrypt the first identifier to obtain an encrypted identifier of the target business object;
[0214] The processing unit 2302 is further used to encode the encrypted identifier to obtain a second identifier of the target business object; the encoding process is used to optimize the identifier attribute of the encrypted identifier;
[0215] The processing unit 2302 is further configured to mark the second identifier of the target business object as the unique object identifier of the target business object.
[0216] In one implementation, the identifier generation information includes: a target timestamp, a node number, and a target sequence number; the target timestamp is used to indicate the generation time of the first identifier; the node number is used to indicate the node device that generates the first identifier; the identifier generation rule supports the generation of multiple identifiers at the same timestamp, and the target sequence number is used to indicate the generation order of the first identifier among the multiple identifiers generated by the target timestamp;
[0217] The generating unit 2301 is used to generate a first identifier for a target business object according to the identifier generation rule, and is specifically used to perform the following steps:
[0218] Generate identifier generation information according to the identifier generation rule;
[0219] Generate a first random number for the target business object according to a random number generation rule;
[0220] The first random number is concatenated with the identifier generation information to obtain a first identifier.
[0221] In one implementation, the node device that generates the first identifier is represented as the target node device; the generating unit 2301 is used to generate the identifier generation information according to the identifier generation rule, specifically to perform the following steps:
[0222] If the current timestamp of the target node device does not overflow under the timestamp length, the current timestamp is determined as the target timestamp;
[0223] If the current timestamp is the same as the local timestamp recorded by the target node device, the local sequence number recorded by the target node device is updated to obtain an updated local sequence number;
[0224] If the updated local sequence number does not overflow under the sequence number length, the updated local sequence number is determined as the target sequence number;
[0225] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0226] In one implementation, the generating unit 2301 is further configured to perform the following steps:
[0227] If the current timestamp is different from the local timestamp recorded by the target node device, the local sequence number recorded by the target node device is reset to obtain a reset local sequence number;
[0228] Determine the reset local sequence number as the target sequence number;
[0229] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0230] In one implementation, the generating unit 2301 is further configured to perform the following steps:
[0231] If the current timestamp overflows under the timestamp length, the local version identifier recorded by the target node device is obtained; the local version identifier is used to indicate the version of the rule adopted by the target node device in the identification generation process, and the rule includes at least one of the following: identification generation rule, encryption rule adopted by encryption processing, and encoding rule adopted by encoding processing;
[0232] Resetting the local timestamp recorded by the target node device to obtain a reset local timestamp, and determining the reset local timestamp as the target timestamp;
[0233] Resetting the local sequence number recorded by the target node device to obtain a reset local sequence number, and determining the reset local sequence number as the target sequence number;
[0234] The local version identifier, target timestamp, node number and target sequence number are concatenated to obtain identifier generation information.
[0235] In one implementation, the generating unit 2301 is further configured to perform the following steps:
[0236] If the updated local sequence number overflows under the sequence number length, wait for the local timestamp to be updated from the current timestamp to the next timestamp of the current timestamp;
[0237] When the local timestamp is updated from the current timestamp to the next timestamp, the updated local sequence number is reset to obtain the reset local sequence number, and the reset local sequence number is determined as the target sequence number; and the next timestamp is determined as the target timestamp;
[0238] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0239] In one implementation, the identification attribute of the encrypted identification includes the identification length of the encrypted identification, the encoding process includes length reduction process; optimization refers to reducing the identification length of the encrypted identification; the encoding process is associated with a coding set, and the coding set includes multiple coding characters; the processing unit 2302 is used to perform the encoding process on the encrypted identification, and when the second identification of the target business object is obtained, it is specifically used to execute the following steps:
[0240] Determine the encrypted identifier as the identifier to be reduced;
[0241] Determine the modulus and quotient between the identifier to be reduced and the size information of the code set; the size information refers to the number of coded characters included in the code set;
[0242] Get the coded character matching the pattern in the coded set;
[0243] The quotient is used to update the identification to be reduced. If the identification to be reduced meets the conditions for continued reduction, the modulus and quotient between the identification to be reduced and the scale information are continuously determined until the identification to be reduced does not meet the conditions for continued reduction.
[0244] When the identifier to be reduced does not meet the conditions for further reduction, the coded characters corresponding to each module are concatenated to obtain the second identifier of the target business object.
[0245] In one implementation, the processing unit 2302 is used to encode the encrypted identifier to obtain the second identifier of the target business object, and is specifically used to perform the following steps:
[0246] Encoding the encrypted identifier to obtain the encoded identifier of the target business object;
[0247] Obtaining an extended identifier corresponding to the first identifier, where the extended identifier is used to extend the identification capability of the first identifier;
[0248] The encoding identifier and the extension identifier are concatenated to obtain a second identifier of the target business object.
[0249] In one implementation, the extended identifier includes a random identifier, the random identifier is used to extend the anti-collision capability of the first identifier, and the random identifier includes one or more character bits; the encoding process is associated with a code set, and the code set includes multiple coded characters; the processing unit 2302 is used to obtain the extended identifier corresponding to the first identifier, and is specifically used to perform the following steps:
[0250] generating a random number generation range according to scale information of the code set, where the scale information refers to the number of code characters included in the code set;
[0251] Based on the random number generation range, generate a second random number for the target character position in the random identifier;
[0252] Determine the coded character in the coded set that matches the second random number as the character corresponding to the target character position;
[0253] The characters corresponding to each character position in the random identifier are concatenated to obtain a random identifier.
[0254] In one implementation, the node device that generates the first identifier is represented as the target node device; the extended identifier includes a version identifier, and the version identifier is used to extend the circulation time capability of the first identifier; the processing unit 2302 is used to obtain the extended identifier corresponding to the first identifier, specifically to perform the following steps:
[0255] Obtaining a local version identifier recorded by the target node device, where the local version identifier is generated based on the local version number recorded by the target node device, and the local version number is used to indicate the version of the rule used by the target node device in the identifier generation process, where the rule includes at least one of the following: an identifier generation rule, an encryption rule used in encryption processing, and an encoding rule used in encoding processing;
[0256] If the rule has not been upgraded, the local version identifier is determined as the version identifier;
[0257] If the rule is upgraded, the local version number is updated, and a version identifier is generated according to the updated local version number.
[0258] In one implementation, the encoding process is associated with a code set, which includes a plurality of coded characters; the extended identifier includes a check identifier, which is used to extend the check capability of the first identifier; the processing unit 2302 is used to obtain the extended identifier corresponding to the first identifier, specifically to perform the following steps:
[0259] Determine verification information corresponding to the coding identifier based on a verification algorithm;
[0260] Determine conversion information according to the scale information of the code set and the number of character digits included in the check mark; the scale information refers to the number of coded characters included in the code set, and the number of character digits refers to the number of characters included in the check mark;
[0261] Convert the verification information according to the conversion information to obtain a conversion identifier of the verification information;
[0262] The conversion identifier is encoded to obtain a verification identifier.
[0263] In one implementation, the generating unit 2301 is further configured to perform the following steps:
[0264] receiving a target generation subtask, the target generation subtask being used to request generation of multiple unique object identifiers of multiple business objects for multiple business objects, the target business object being any one of the multiple business objects; the target generation subtask being any generation subtask obtained by dividing the identifier generation task;
[0265] Execute the target generation subtask to generate unique object identifiers of multiple business objects for the multiple business objects;
[0266] Among them, the target generation subtask is executed by any node device in the business system, and the business system divides the identifier generation task into multiple generation subtasks according to the identifier generation capability information of the business system; the identifier generation capability information is used to indicate the upper limit of the number of identifiers that each node device in the business system can generate per unit time; a node device in the business system is used to execute a generation subtask.
[0267] According to one embodiment of the present application, Fig.23The various units in the identification generation device shown can be combined into one or several other units separately or in whole, or one (some) of the units can be further divided into multiple smaller units in function to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the functions of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the identification generation device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0268] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 6 or Fig.14 A computer program for each step involved in part or all of the method shown in the figure is used to construct a computer program for each step involved in part or all of the method shown in the figure. Fig.23 The identification generation device shown in and the identification generation method of the embodiment of the present application are implemented. The computer program can be recorded on, for example, a computer-readable storage medium, and loaded into the above-mentioned computing device through the computer-readable storage medium and run therein.
[0269] In the embodiment of the present application, the first identifier generated for the business object can be encrypted and encoded to obtain a second identifier, and the second identifier can be marked as the unique object identifier of the business object; the first identifier can include identifier generation information, and the identifier generation information is unique. The first identifier can uniquely identify the target business object through the identifier generation information, thereby ensuring the uniqueness of the object identifier generated for the business object. In addition, the security of the object identifier generated for the business object can be improved through encryption processing; and the identification attribute of the object identifier generated for the business object can be optimized through encoding processing.
[0270] Based on the above method and device embodiments, the present application embodiment provides a computer device. Fig.24 , Fig.24 It is a structural diagram of a computer device provided in an embodiment of the present application. Fig.24 The computer device shown includes at least a processor 2401, an input interface 2402, an output interface 2403, and a computer-readable storage medium 2404. The processor 2401, the input interface 2402, the output interface 2403, and the computer-readable storage medium 2404 may be connected via a bus or other means.
[0271] The computer-readable storage medium 2404 may be stored in a memory of a computer device. The computer-readable storage medium 2404 is used to store a computer program. The computer program includes computer instructions. The processor 2401 is used to execute the computer program stored in the computer-readable storage medium 2404. The processor 2401 (or CPU (Central Processing Unit)) is the computing core and control core of the computer device, which is suitable for implementing a computer program, and is specifically suitable for loading and executing a computer program to implement a corresponding method flow or a corresponding function.
[0272] The embodiment of the present application also provides a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides a storage space that stores the operating system of the computer device. In addition, a computer program suitable for being loaded and executed by a processor is also stored in the storage space. It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory (Non-Volatile Memory), such as at least one disk storage; optionally, it can also be at least one computer-readable storage medium located away from the aforementioned processor.
[0273] The computer device may be any node device in the business system (which may be represented as a target node device). In a specific implementation, the processor 2401 may load and execute a computer program stored in the computer-readable storage medium 2404 to implement the above-mentioned Figure 6 or Fig.14 In a specific implementation, the computer program in the computer-readable storage medium 2404 is loaded by the processor 2401 and executes the following steps:
[0274] Generate a first identifier for the target business object according to the identifier generation rule; the first identifier includes identifier generation information, and the first identifier uniquely identifies the target business object through the identifier generation information;
[0275] Encrypting the first identifier to obtain an encrypted identifier of the target business object;
[0276] The encrypted identifier is encoded to obtain a second identifier of the target business object; the encoding process is used to optimize the identifier attribute of the encrypted identifier;
[0277] The second identifier of the target business object is marked as the unique object identifier of the target business object.
[0278] In one implementation, the identifier generation information includes: a target timestamp, a node number, and a target sequence number; the target timestamp is used to indicate the generation time of the first identifier; the node number is used to indicate the node device that generates the first identifier; the identifier generation rule supports the generation of multiple identifiers at the same timestamp, and the target sequence number is used to indicate the generation order of the first identifier among the multiple identifiers generated by the target timestamp;
[0279] When the computer program in the computer-readable storage medium 2404 is loaded and executed by the processor 2401 to generate a first identifier for the target business object according to the identifier generation rule, the computer program is specifically used to perform the following steps:
[0280] Generate identifier generation information according to the identifier generation rule;
[0281] Generate a first random number for the target business object according to a random number generation rule;
[0282] The first random number is concatenated with the identifier generation information to obtain a first identifier.
[0283] In one implementation, the node device that generates the first identifier is represented as a target node device; when the computer program in the computer-readable storage medium 2404 is loaded and executed by the processor 2401 to generate identifier generation information according to the identifier generation rule, it is specifically used to perform the following steps:
[0284] If the current timestamp of the target node device does not overflow under the timestamp length, the current timestamp is determined as the target timestamp;
[0285] If the current timestamp is the same as the local timestamp recorded by the target node device, the local sequence number recorded by the target node device is updated to obtain an updated local sequence number;
[0286] If the updated local sequence number does not overflow under the sequence number length, the updated local sequence number is determined as the target sequence number;
[0287] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0288] In one implementation, the computer program in the computer-readable storage medium 2404 is loaded by the processor 2401 and is further used to perform the following steps:
[0289] If the current timestamp is different from the local timestamp recorded by the target node device, the local sequence number recorded by the target node device is reset to obtain a reset local sequence number;
[0290] Determine the reset local sequence number as the target sequence number;
[0291] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0292] In one implementation, the computer program in the computer-readable storage medium 2404 is loaded by the processor 2401 and is further used to perform the following steps:
[0293] If the current timestamp overflows under the timestamp length, the local version identifier recorded by the target node device is obtained; the local version identifier is used to indicate the version of the rule adopted by the target node device in the identification generation process, and the rule includes at least one of the following: identification generation rule, encryption rule adopted by encryption processing, and encoding rule adopted by encoding processing;
[0294] Resetting the local timestamp recorded by the target node device to obtain a reset local timestamp, and determining the reset local timestamp as the target timestamp;
[0295] Resetting the local sequence number recorded by the target node device to obtain a reset local sequence number, and determining the reset local sequence number as the target sequence number;
[0296] The local version identifier, target timestamp, node number and target sequence number are concatenated to obtain identifier generation information.
[0297] In one implementation, the computer program in the computer-readable storage medium 2404 is loaded by the processor 2401 and is further used to perform the following steps:
[0298] If the updated local sequence number overflows under the sequence number length, wait for the local timestamp to be updated from the current timestamp to the next timestamp of the current timestamp;
[0299] When the local timestamp is updated from the current timestamp to the next timestamp, the updated local sequence number is reset to obtain the reset local sequence number, and the reset local sequence number is determined as the target sequence number; and the next timestamp is determined as the target timestamp;
[0300] The target timestamp, node number and target sequence number are concatenated to obtain the identification generation information.
[0301] In one implementation, the identification attribute of the encrypted identification includes the identification length of the encrypted identification, the encoding process includes length reduction process; optimization refers to reducing the identification length of the encrypted identification; the encoding process is associated with a code set, and the code set includes multiple encoding characters; the computer program in the computer-readable storage medium 2404 is loaded and executed by the processor 2401 to encode the encrypted identification, and when the second identification of the target business object is obtained, it is specifically used to execute the following steps:
[0302] Determine the encrypted identifier as the identifier to be reduced;
[0303] Determine the modulus and quotient between the identifier to be reduced and the size information of the code set; the size information refers to the number of coded characters included in the code set;
[0304] Get the coded character matching the pattern in the coded set;
[0305] The quotient is used to update the identification to be reduced. If the identification to be reduced meets the conditions for continued reduction, the modulus and quotient between the identification to be reduced and the scale information are continuously determined until the identification to be reduced does not meet the conditions for continued reduction.
[0306] When the identifier to be reduced does not meet the conditions for further reduction, the coded characters corresponding to each module are concatenated to obtain the second identifier of the target business object.
[0307] In one implementation, the computer program in the computer-readable storage medium 2404 is loaded by the processor 2401 and executed to encode the encrypted identifier, and when the second identifier of the target business object is obtained, it is specifically used to perform the following steps:
[0308] Encoding the encrypted identifier to obtain the encoded identifier of the target business object;
[0309] Obtaining an extended identifier corresponding to the first identifier, where the extended identifier is used to extend the identification capability of the first identifier;
[0310] The encoding identifier and the extension identifier are concatenated to obtain a second identifier of the target business object.
[0311] In one implementation, the extended identifier includes a random identifier, the random identifier is used to extend the anti-collision capability of the first identifier, and the random identifier includes one or more character bits; the encoding process is associated with a code set, and the code set includes multiple coded characters; when the computer program in the computer-readable storage medium 2404 is loaded and executed by the processor 2401 to obtain the extended identifier corresponding to the first identifier, it is specifically used to perform the following steps:
[0312] generating a random number generation range according to scale information of the code set, where the scale information refers to the number of code characters included in the code set;
[0313] Based on the random number generation range, generate a second random number for the target character position in the random identifier;
[0314] Determine the coded character in the coded set that matches the second random number as the character corresponding to the target character position;
[0315] The characters corresponding to each character position in the random identifier are concatenated to obtain a random identifier.
[0316] In one implementation, the node device that generates the first identifier is represented as the target node device; the extended identifier includes a version identifier, and the version identifier is used to extend the circulation time capability of the first identifier; when the computer program in the computer-readable storage medium 2404 is loaded and executed by the processor 2401 to obtain the extended identifier corresponding to the first identifier, it is specifically used to perform the following steps:
[0317] Obtaining a local version identifier recorded by the target node device, where the local version identifier is generated based on the local version number recorded by the target node device, and the local version number is used to indicate the version of the rule used by the target node device in the identifier generation process, where the rule includes at least one of the following: an identifier generation rule, an encryption rule used in encryption processing, and an encoding rule used in encoding processing;
[0318] If the rule has not been upgraded, the local version identifier is determined as the version identifier;
[0319] If the rule is upgraded, the local version number is updated, and a version identifier is generated according to the updated local version number.
[0320] In one implementation, the encoding process is associated with a code set, which includes a plurality of coded characters; the extended identifier includes a check identifier, which is used to extend the check capability of the first identifier; when the computer program in the computer-readable storage medium 2404 is loaded and executed by the processor 2401 to obtain the extended identifier corresponding to the first identifier, it is specifically used to perform the following steps:
[0321] Determine verification information corresponding to the coding identifier based on a verification algorithm;
[0322] Determine conversion information according to the scale information of the code set and the number of character digits included in the check mark; the scale information refers to the number of coded characters included in the code set, and the number of character digits refers to the number of characters included in the check mark;
[0323] Convert the verification information according to the conversion information to obtain a conversion identifier of the verification information;
[0324] The conversion identifier is encoded to obtain a verification identifier.
[0325] In one implementation, the computer program in the computer-readable storage medium 2404 is loaded by the processor 2401 and is further used to perform the following steps:
[0326] receiving a target generation subtask, the target generation subtask being used to request generation of multiple unique object identifiers of multiple business objects for multiple business objects, the target business object being any one of the multiple business objects; the target generation subtask being any generation subtask obtained by dividing the identifier generation task;
[0327] Execute the target generation subtask to generate unique object identifiers of multiple business objects for the multiple business objects;
[0328] Among them, the target generation subtask is executed by any node device in the business system, and the business system divides the identifier generation task into multiple generation subtasks according to the identifier generation capability information of the business system; the identifier generation capability information is used to indicate the upper limit of the number of identifiers that each node device in the business system can generate per unit time; a node device in the business system is used to execute a generation subtask.
[0329] In the embodiment of the present application, the first identifier generated for the business object can be encrypted and encoded to obtain a second identifier, and the second identifier can be marked as the unique object identifier of the business object; the first identifier can include identifier generation information, and the identifier generation information is unique. The first identifier can uniquely identify the target business object through the identifier generation information, thereby ensuring the uniqueness of the object identifier generated for the business object. In addition, the security of the object identifier generated for the business object can be improved through encryption processing; and the identification attribute of the object identifier generated for the business object can be optimized through encoding processing.
[0330] The embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the above-mentioned identification generation method.
[0331] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0332] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0333] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing computer program instructions on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted by a computer-readable storage medium. The computer instructions can be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
[0334] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for generating an identifier, It is characterized in that include: Generate a first identifier for the target business object according to an identifier generation rule; The first identifier includes identifier generation information, and the first identifier uniquely identifies the target business object through the identifier generation information; the identifier generation information includes a target timestamp; Encrypting the first identifier to obtain an encrypted identifier of the target business object; Optimizing the encrypted identifier to obtain a second identifier of the target business object; The second identifier of the target business object is marked as the object identifier of the target business object.
2. The method according to claim 1, It is characterized in that The target timestamp is used to indicate the generation time of the first identifier; The identification generation information also includes a node number, and the node number is used to indicate a node device that generates the first identification.
3. The method according to claim 1 or 2, It is characterized in that The identification generation information also includes a target sequence number; The identifier generation rule supports generating multiple identifiers at the same timestamp, and the target sequence number is used to indicate the generation order of the first identifier among the multiple identifiers generated at the target timestamp.
4. The method according to claim 1, It is characterized in that Generating a first identifier for the target business object according to the identifier generation rule includes: Generate the identifier generation information according to the identifier generation rule; Generate a first random number for the target business object according to a random number generation rule; The first random number is concatenated with the identifier generation information to obtain the first identifier.
5. The method according to claim 4, It is characterized in that The step of generating the identifier generation information according to the identifier generation rule includes: If the current timestamp does not overflow under the timestamp length, determining the current timestamp as the target timestamp; If the current timestamp is the same as the recorded local timestamp, the recorded local sequence number is updated to obtain an updated local sequence number; If the updated local sequence number does not overflow under the sequence number length, determining the updated local sequence number as the target sequence number; The target timestamp, the node number and the target sequence number are concatenated to obtain the identification generation information.
6. The method according to claim 5, It is characterized in that The method further comprises: If the current timestamp is different from the recorded local timestamp, the recorded local sequence number is reset to obtain a reset local sequence number; Determining the reset local sequence number as a target sequence number; The target timestamp, the node number and the target sequence number are concatenated to obtain the identification generation information.
7. The method according to claim 5, It is characterized in that The method further comprises: If the current timestamp overflows under the timestamp length, a local version identifier of the record is obtained; the local version identifier is used to indicate the version of the rule used in the identifier generation process; Resetting the recorded local timestamp to obtain a reset local timestamp, and determining the reset local timestamp as the target timestamp; Resetting the recorded local sequence number to obtain a reset local sequence number, and determining the reset local sequence number as the target sequence number; The local version identifier, the target timestamp, the node number and the target sequence number are concatenated to obtain the identifier generation information.
8. The method according to claim 5, It is characterized in that The method further comprises: If the updated local sequence number overflows under the sequence number length, waiting for the local timestamp to be updated from the current timestamp to the next timestamp of the current timestamp; When the local timestamp is updated from the current timestamp to the next timestamp, the updated local sequence number is reset to obtain a reset local sequence number, and the reset local sequence number is determined as a target sequence number; and, Determine the next timestamp as a target timestamp; The target timestamp, the node number and the target sequence number are concatenated to obtain the identification generation information.
9. The method according to claim 1, It is characterized in that The step of optimizing the encrypted identifier to obtain the second identifier of the target business object includes: Encoding the encrypted identifier to obtain a second identifier of the target business object; The encoding process is used to optimize the identification attribute of the encrypted identification.
10. The method according to claim 9, It is characterized in that The identification attribute of the encrypted identification includes the identification length of the encrypted identification, the encoding process includes length reduction process; the optimization refers to reducing the identification length of the encrypted identification; the encoding process of the encrypted identification to obtain the second identification of the target business object includes: Determine the encrypted identifier as the identifier to be reduced; Determine the modulus and quotient between the identifier to be reduced and the scale information of the code set; the scale information refers to the number of coded characters included in the code set associated with the coding process; Obtaining a coded character matching the pattern in the coded set; The to-be-reduced identifier is updated by using the quotient, and if the to-be-reduced identifier satisfies the continued reduction condition, the modulus and quotient between the to-be-reduced identifier and the scale information are continuously determined until the to-be-reduced identifier does not satisfy the continued reduction condition; When the identifier to be reduced does not meet the further reduction condition, the coded characters corresponding to the modules are concatenated to obtain the second identifier of the target business object.
11. The method according to claim 1, It is characterized in that The step of optimizing the encrypted identifier to obtain the second identifier of the target business object includes: Performing encoding processing on the encrypted identifier to obtain the encoded identifier of the target business object; the encoding processing is used to optimize the identifier attribute of the encrypted identifier; Acquire an extended identifier corresponding to the first identifier, where the extended identifier is used to extend the identification capability of the first identifier; The encoding identifier and the extension identifier are concatenated to obtain a second identifier of the target business object.
12. The method according to claim 11, It is characterized in that The extended identifier includes a random identifier, the random identifier is used to extend the anti-collision capability of the first identifier, and the random identifier includes one or more character bits; and obtaining the extended identifier corresponding to the first identifier includes: generating a random number generation range according to scale information of the code set, wherein the scale information refers to the number of coded characters included in the code set associated with the coding process; Based on the random number generation range, generating a second random number for the target character position in the random identifier; Determine the coded character in the coded set that matches the second random number as the character corresponding to the target character position; The characters corresponding to the respective character positions in the random identifier are concatenated to obtain the random identifier.
13. The method according to claim 11, It is characterized in that The extended identifier includes a version identifier, and the version identifier is used to extend the circulation time capability of the first identifier; and obtaining the extended identifier corresponding to the first identifier includes: Obtaining a local version identifier of the record, wherein the local version identifier is generated according to a local version number of the record, wherein the local version number is used to indicate a version of a rule used in an identifier generation process; If the rule has not been upgraded, the local version identifier is determined as the version identifier; If the rule is upgraded, the local version number is updated, and the version identifier is generated according to the updated local version number.
14. The method according to claim 11, It is characterized in that The extended identifier includes a verification identifier, and the verification identifier is used to extend the verification capability of the first identifier; and obtaining the extended identifier corresponding to the first identifier includes: Determine verification information corresponding to the coding identifier based on a verification algorithm; Determine conversion information according to the scale information of the code set and the number of character digits contained in the check mark; the scale information refers to the number of coded characters included in the code set associated with the coding process, and the number of character digits refers to the number of characters contained in the check mark; Convert the verification information according to the conversion information to obtain a conversion identifier of the verification information; The conversion identifier is encoded to obtain the verification identifier.
15. The method of claim 1, It is characterized in that The method further comprises: Receive a target generation subtask, the target generation subtask is used to request to generate unique object identifiers of multiple business objects for the multiple business objects, the target business object is any one of the multiple business objects; the target generation subtask is any generation subtask obtained by dividing the identifier generation task; Execute the target generation subtask to generate unique object identifiers for the multiple business objects; Among them, the target generation subtask is executed by any node device in the business system, and the business system divides the identifier generation task into multiple generation subtasks according to the identifier generation capability information of the business system; the identifier generation capability information is used to indicate the upper limit of the number of identifiers that each node device in the business system can generate per unit time; a node device in the business system is used to execute one of the generation subtasks.
16. The method of claim 1, It is characterized in that The method further comprises: Associating the object identifier of the target business object with the target business object; or, Associating the object identifier of the target business object with the object information of the target business object; The method of using the object identifier of the target business object includes: using the object identifier of the target business object, or using a graphic code corresponding to the object identifier of the target business object.
17. An identification generating device, It is characterized in that include: A generating unit, configured to generate a first identifier for a target business object according to an identifier generation rule; The first identifier includes identifier generation information, and the first identifier uniquely identifies the target business object through the identifier generation information; the identifier generation information includes a target timestamp; A processing unit, configured to encrypt the first identifier to obtain an encrypted identifier of the target business object; The processing unit is further used to optimize the encrypted identifier to obtain a second identifier of the target business object; The processing unit is further configured to mark the second identifier of the target business object as the object identifier of the target business object.
18. A computer device, It is characterized in that The computer device comprises: a processor suitable for implementing a computer program; A computer-readable storage medium storing a computer program, wherein the computer-readable storage medium stores a computer program, wherein the computer program is suitable for being loaded by the processor and executing the identification generation method according to any one of claims 1 to 16.
19. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the identification generation method according to any one of claims 1 to 16.
20. A computer program product, It is characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the identification generation method according to any one of claims 1 to 16 is implemented.
