Resource identifier generation method, apparatus, device, and storage medium
By generating a resource identifier consisting of a service unit, an encryption unit, an activity unit, and a change unit in a distributed system, the problem of insufficient flexibility and scalability in the generation of resource identifiers in existing technologies is solved, and globally unique and secure identifier generation is achieved, which is applicable to various distributed systems.
Patent Information
- Application Number
- CN202010330680.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-24
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2040-04-24
AI Technical Summary
Existing technologies for generating resource identifiers in distributed systems rely excessively on distributed components, resulting in insufficient flexibility and scalability. This limits the applicability of these technologies to various application scenarios and makes it difficult to generate globally unique and flexible resource identifiers without relying on existing open-source components.
A resource identifier generation method is adopted, which generates a resource identifier composed of a service department, an encryption department, an activity department, and a change department by obtaining the identifier structure information and delimiter information, and then uses delimiters to splice the identifiers to ensure the uniqueness and scalability of the identifiers.
Generate globally unique and flexibly scalable resource identifiers in distributed systems, reducing generation difficulty, saving management costs, and improving the security and reliability of the identifiers.
Smart Images

Figure CN113553518B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of distributed computing, and more particularly to a method, apparatus, device, and storage medium for generating resource identifiers. Background Technology
[0002] With the rise of cloud computing, a large number of computers can obtain theoretically infinitely scalable computing power, storage space and information services through cloud interaction. While various computers achieve resource sharing through cloud interaction, it also brings about the technical problem of how to ensure the uniqueness of resource identification in a distributed system that supports cloud computing.
[0003] To ensure the uniqueness of resource identifiers in a distributed system, existing technologies offer various feasible solutions, such as using database auto-incrementing identifiers, having the server generate identifiers by combining relevant local parameters, or generating identifiers based on existing distributed components. However, these existing technologies either over-rely on distributed components or lack scalability and flexibility, thus limiting their applicability to various scenarios and consequently impacting their application prospects to some extent. Summary of the Invention
[0004] Existing technologies that ensure the uniqueness of resource identifiers each have their own advantages and disadvantages, applicable scenarios, and limitations. Currently, no single solution can generate arbitrarily extensible resource identifiers with high flexibility without relying on existing open-source components. Therefore, embodiments of the present invention provide a resource identifier generation method, apparatus, device, and storage medium.
[0005] On one hand, the present invention provides a resource identifier generation method, the method comprising:
[0006] Obtain a resource identifier generation strategy, which includes identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the substructure and the adjacency relationship of the substructure. The substructure includes at least a service substructure and a change substructure. The service substructure points to a service associated with the resource identifier, and the change substructure points to a field that ensures the resource identifier is unique.
[0007] Extract the sub-structures from the identifier structure information, and obtain the splicing information corresponding to each sub-structure;
[0008] Obtain the separator based on the separator information;
[0009] Based on the adjacency relationship of the substructures in the identifier structure information, the adjacent information to be spliced is connected by the separator to obtain the resource identifier.
[0010] On the other hand, the present invention provides a method for verifying resource identifiers, the method comprising:
[0011] Obtain a resource identifier and a corresponding resource identifier generation strategy. The resource identifier generation strategy includes identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the substructure and the adjacency relationship of the substructure. The substructure includes at least a service substructure and a change substructure. The service substructure points to a service associated with the resource identifier, and the change substructure points to a field that ensures the resource identifier is unique.
[0012] The resource identifier is parsed according to the resource identifier strategy to obtain the parsing results of each information section and the parsing results of the verification section. The information section is the other part structure in the resource identifier that is different from the verification section.
[0013] Calculate the target verification information based on the parsing results corresponding to each information department;
[0014] If the target verification information matches the parsing result of the verification unit, the verification passes.
[0015] On the other hand, the present invention provides a resource identifier generation apparatus, the apparatus comprising:
[0016] The resource identifier generation strategy acquisition module is used to acquire a resource identifier generation strategy. The resource identifier generation strategy includes identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the substructure and the adjacency relationship of the substructure. The substructure includes at least a service substructure and a change substructure. The service substructure points to a service associated with the resource identifier, and the change substructure points to a field that ensures the resource identifier has uniqueness.
[0017] The module for generating information to be spliced is used to extract the sub-structures from the identifier structure information and obtain the information to be spliced corresponding to each sub-structure;
[0018] A separator acquisition module is used to acquire separators based on the separator information;
[0019] The resource identifier acquisition module is used to obtain resource identifiers by connecting adjacent information to be spliced using the separator based on the adjacency relationship of the substructures in the identifier structure information.
[0020] On the other hand, the present invention provides a resource identifier verification device, the device comprising:
[0021] The resource identifier acquisition module is used to acquire a resource identifier and a resource identifier generation strategy corresponding to the resource identifier. The resource identifier generation strategy includes identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the substructure and the adjacency relationship of the substructure. The substructure includes at least a service substructure and a change substructure. The service substructure points to a service associated with the resource identifier, and the change substructure points to a field that ensures the resource identifier has uniqueness.
[0022] The parsing module is used to parse the resource identifier according to the resource identifier strategy to obtain the parsing results corresponding to each information section and the parsing results of the verification section. The information section is the other part structure of the resource identifier that is different from the verification section.
[0023] The target verification information calculation module is used to calculate the target verification information based on the parsing results corresponding to each information section.
[0024] The verification module is used to verify that if the target verification information is consistent with the parsing result of the verification unit, the verification passes.
[0025] On the other hand, the present invention provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores at least one instruction or at least one program, wherein the at least one instruction or at least one program is loaded and executed by a processor to implement the above-described resource identifier generation method or resource identifier verification method.
[0026] On the other hand, the present invention provides a resource identifier processing device, characterized in that the device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or at least one program being loaded and executed by the processor as described above in a resource identifier generation method or a resource identifier verification method.
[0027] This invention provides a method, apparatus, device, and storage medium for generating resource identifiers. By generating resource identifiers through a process of obtaining information from multiple component structures according to a resource identifier generation strategy and concatenating this information based on delimiters, this invention ensures that in a distributed system, each server only needs to independently generate its own resource identifier, guaranteeing global uniqueness within the distributed system. This saves on global management costs and reduces the difficulty of resource identifier generation. Furthermore, the component structures of the resource identifier can be arbitrarily expanded, and the length of the resource identifier is not fixed, theoretically supporting the generation of resource identifiers of arbitrary granularity and length. Attached Figure Description
[0028] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a schematic diagram of the implementation environment of a resource identifier generation method provided by the present invention;
[0030] Figure 2 This is a flowchart of a resource identifier generation method provided by the present invention;
[0031] Figure 3 This is a schematic diagram of the resource identifier provided by the present invention;
[0032] Figure 4 This is a flowchart provided by the present invention for extracting the sub-structures from the identifier structure information and obtaining the information to be spliced corresponding to each sub-structure;
[0033] Figure 5 This is a flowchart provided by the present invention for obtaining an encrypted string according to a preset encryption algorithm;
[0034] Figure 6 This is a flowchart provided by the present invention for obtaining the information to be spliced corresponding to each component structure in the case of transcoding;
[0035] Figure 7 This is a flowchart of the information generation method for the verification section provided by the present invention;
[0036] Figure 8 This is a flowchart of the resource identifier verification method provided by the present invention;
[0037] Figure 9 This is a block diagram of a resource identifier generation device provided by the present invention;
[0038] Figure 10 This is a block diagram of a resource identifier verification device provided by the present invention;
[0039] Figure 11 This is a schematic diagram of the hardware structure of a device for implementing the method provided in the embodiments of the present invention. Detailed Implementation
[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0042] To make the objectives, technical solutions, and advantages disclosed in the embodiments of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the embodiments of the present invention and are not intended to limit the embodiments of the present invention.
[0043] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "multiple" means two or more. To facilitate understanding of the technical solutions described in the embodiments of the present invention and their resulting technical effects, the embodiments of the present invention first explain the relevant technical terms:
[0044] MySQL: A relational database management system.
[0045] Redis, or Remote Dictionary Server, is an open-source, network-enabled, in-memory or persistent, log-structured, key-value database that provides application programming interfaces (APIs) in multiple languages.
[0046] Twitter Snowflake algorithm: is a distributed identifier generation algorithm open-sourced by Twitter.
[0047] Zookeeper is a distributed, open-source distributed application coordination service.
[0048] Number system conversion: Based on different mathematical number systems, numerical values are converted to obtain different display results. For the same value, the higher the number system used, the fewer bits are required.
[0049] ASCII: American Standard Code for Information Interchange. It is a computer encoding system based on the Latin alphabet, primarily used to display modern English and other Western European languages.
[0050] Cloud computing refers to obtaining necessary resources in an on-demand and easily scalable manner through a network. In a broader sense, cloud computing refers to a service delivery and usage model, meaning obtaining necessary services in an on-demand and easily scalable manner through a network. These services can be IT and software-related, internet-related, or other services. Cloud computing is a product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing.
[0051] With the development of the internet, real-time data streams, and the diversification of connected devices, as well as the demands for search services, social networks, mobile commerce, and open collaboration, cloud computing has rapidly developed. Unlike previous parallel distributed computing, cloud computing will fundamentally revolutionize the entire internet model and enterprise management model.
[0052] To generate unique resource identifiers in distributed systems that support cloud computing, existing technologies offer several feasible solutions:
[0053] (1) Utilizing database auto-incrementing identifiers
[0054] You can implement auto-incrementing identifiers using MySQL's `auto_increment` field or Redis. Different step sizes can be set to generate unique identifiers for different application scenarios. Using database auto-incrementing identifiers ensures uniqueness and order, and is simple to use; however, it requires independent deployment of the database or Redis instance, resulting in higher costs and performance bottlenecks.
[0055] (2) The server generates an identifier by combining relevant local parameters of the server.
[0056] A unique identifier can be calculated by the server using the local network card address, local time, and a random number. The server can generate the identifier locally using these parameters, making it simple to use and high-performing, suitable for distributed application scenarios. However, this method generates identifiers with a fixed format, long length, and consumes significant storage space; furthermore, the identifiers are unordered and unreadable.
[0057] (3) Twitter snowflake algorithm
[0058] Twitter's Snowflake algorithm generates 64-bit identifiers, consisting of four fields: a 1-bit sign bit, a 41-bit timestamp difference, a 10-bit machine ID, and a 12-bit auto-incrementing identifier within milliseconds. This ensures identifier uniqueness in distributed scenarios, boasts high generation performance, and maintains temporal order. However, this approach requires independent development and deployment, relies on the server's local time, and has length limitations due to the timestamp difference and machine ID fields, thus limiting the size of the unique identifiers it can support.
[0059] (4) Generate identifiers based on existing open-source components that support distributed systems.
[0060] Relying on components such as databases and Zookeeper to generate identifiers, it can ensure that the resource identifiers obtained in distributed scenarios are globally unique, monotonically increasing, and highly secure.
[0061] Existing technologies that ensure the uniqueness of resource identifiers each have their own advantages and disadvantages, applicable scenarios, and limitations. Currently, no single solution can generate arbitrarily extensible resource identifiers with high flexibility without relying on existing open-source components. Therefore, this invention provides a resource identifier generation method, aiming to offer such a resource identifier generation solution:
[0062] (1) It has good scalability and can be applied to different application scenarios. It can ensure the overall incremental trend of distributed generated resource identifiers and is globally unique. Resource identifiers generated in different applications can be indexed to the corresponding services.
[0063] (2) It can guarantee the information security of the unique resource identifier. Users cannot obtain any intrinsic information from the resource identifier itself, and therefore cannot forge the resource identifier. Even if the algorithm for generating the resource identifier is leaked, it is impossible to directly reproduce the generated resource identifier through the algorithm. It still requires brute-force polling, which increases the difficulty of cracking.
[0064] (3) For each resource identifier, a legality check can be performed, and the execution efficiency is good.
[0065] First, this invention discloses an implementation environment for a resource identifier generation method described in a feasible embodiment.
[0066] See Figure 1 The implementation environment includes at least one client 01 and a server 03.
[0067] Client 01 may be a physical device for interacting with server 03. Client 01 may also include software running on the physical device, such as programs that can access services provided by server 03 and interact with server 03. Client 01 may communicate with server 03 based on either a browser / server (B / S) or client / server (C / S) model.
[0068] The server 03 can be a distributed server or any one of the servers in a server cluster. The server 03 supports cloud computing in a distributed architecture and provides cloud services. Any one of the servers 03 can independently run the resource identifier generation method to obtain a unique resource identifier that can be indexed to the services provided by that server.
[0069] This invention provides a method for generating resource identifiers, such as... Figure 2 As shown, the method can run on a server in a distributed system, and the method includes:
[0070] S101. Obtain a resource identifier generation strategy, wherein the resource identifier generation strategy includes identifier structure information and delimiter information, wherein the identifier structure information is used to characterize the information of the substructure and the adjacency relationship of the substructure, wherein the substructure includes at least a service substructure and a change substructure, wherein the service substructure points to a service associated with the resource identifier, and the change substructure points to a field that ensures the resource identifier has uniqueness.
[0071] In this embodiment of the invention, the generated resource identifier can be composed of multiple substructures. The content and adjacency relationships of each substructure are recorded in the identifier structure information. The resource identifier must include at least a service substructure and a change substructure. The service substructure points to the service associated with the resource identifier. This service needs to use the resource identifier or the service is used to generate the resource identifier, so that the service can be indexed based on the resource identifier. It also ensures that the resource identifiers corresponding to different services in the distributed system are necessarily different, which is a necessary condition for ensuring the uniqueness of the resource identifier. The change substructure points to the changing fields in the resource identifier. Even if the same server generates resource identifiers based on the same service, the content of the fields pointed to by their change substructures will necessarily be different, thereby ensuring the uniqueness of the resource identifier.
[0072] like Figure 3 As shown, a resource identifier in a feasible embodiment is illustrated. This resource identifier consists of a service section, an encryption section, an activity section, and a variation section. The resource identifier is obtained by sequentially concatenating the contents of the service section, encryption section, activity section, and variation section using delimiters. Specifically, the contents of each section are as follows:
[0073] Service Department: Includes business fields and machine numbers. The resource identifier is a resource identifier generated by the machine corresponding to the machine number for the business corresponding to the business field. The setting of the service department enables the resource identifier generation method provided in this embodiment to support expansion by business and by machine. Different businesses and machines, after being assigned different numbers, can independently implement the resource identifier generation method.
[0074] Encryption Section: When there is a length requirement for the resource identifier, an encryption section can be set to pad the length. This encryption section can be generated using an encryption algorithm to enhance the security of the resource identifier. Even if the resource identifier generation algorithm is leaked, the resource identifier cannot be directly reproduced. The encryption section can be constructed using a random string. The encryption section itself can be ciphertext or plaintext. The purpose of setting up the encryption section is to pad the length of the resource identifier and increase the difficulty of cracking the resource identifier.
[0075] Activity Department: The activity department is scalable, allowing resource identifier generation to meet arbitrary granularity requirements. The activity department can include at least one level of activity identifiers, and these identifiers can also be multi-level identifiers; the more levels of activity identifiers, the finer the granularity. This activity department configuration enables the resource identifier generation method in this embodiment to support not only single-service, single-machine, and single-activity granularity resource identifier generation, but also resource identifier generation for activities of arbitrary granularity, thus allowing resource identifiers to be generated in batches.
[0076] Variation section: The variation section is related to the activity section and is used to distinguish between various resource identifiers generated for the same activity. The variation section can be generated by setting a step size and performing an auto-incrementing rule.
[0077] In a preferred embodiment, to facilitate the verification of the resource identifier, the resource identifier may further include a verification part, which may be attached to the end of the resource identifier or other designated location.
[0078] The purpose of using delimiters to divide the various substructures in the resource identifier is to allow the length of the content corresponding to each substructure to be flexible and not fixed, and to make the resource identifier scalable, allowing the length of each substructure and the overall length of the resource identifier to be varied as needed. In a preferred embodiment, the identifier corresponding to the delimiter is an identifier not present in the content corresponding to each substructure, thus achieving the segmentation effect.
[0079] Figure 3 In this code, "EB" stands for Service Department, "HB" for Encryption Department, "4U" for Activity Department, "HBT" for Change Department, "8" for Verification Department, and "Z" for Separator.
[0080] S103. Extract the sub-structures from the identifier structure information and obtain the splicing information corresponding to each sub-structure.
[0081] Specifically, the step of extracting the sub-structures from the identifier structure information and obtaining the concatenation information corresponding to each sub-structure is as follows: Figure 4 As shown, it includes:
[0082] S1031. Obtain the service identifier pointed to by the resource identifier and the server identifier of the server, and obtain the first information corresponding to the service department based on the service identifier and the server identifier.
[0083] S1033. Obtain the second information corresponding to the changed part based on the local auto-increment algorithm.
[0084] Unlike existing auto-incrementing algorithms for generating identifiers in distributed systems, which require global incrementing to ensure uniqueness, this invention addresses the issue of the variable part being generated solely through local server-side auto-incrementing. This eliminates the need to consider other servers or components within the distributed system, as different servers generate resource identifiers for different servers. Therefore, the variable part can be derived solely from the local server-side auto-incrementing algorithm, significantly reducing the complexity compared to existing technologies. The local server-side auto-incrementing algorithm can be implemented using existing techniques, and this invention does not limit its specific implementation methods.
[0085] Specifically, the server-local auto-increment algorithm can be implemented using existing database auto-increment algorithms, such as using MySQL's auto_increment field or Redis. Because the auto-increment in this embodiment does not need to consider the global situation, but only needs to ensure that changes in the resource identifier within a single server do not increment, it can support parallel scaling and will not encounter single-point performance bottlenecks.
[0086] In a preferred embodiment, the identifier structure information further includes an encryption part, an activity part, and a verification part. The step of extracting the part structures from the identifier structure information and obtaining the concatenation information corresponding to each part structure further includes:
[0087] S1035. Obtain an encrypted string according to a preset encryption algorithm, and use the encrypted string as the third information corresponding to the encryption part.
[0088] In one feasible embodiment, the encrypted string is obtained according to a preset encryption algorithm, such as... Figure 5 As shown, it includes:
[0089] S10351. Obtain the target length of the encryption part.
[0090] Specifically, the target length can be determined according to actual needs and can be flexibly increased or decreased.
[0091] S10353. Randomly select a target length number of characters from the encrypted character mapping table to form an encrypted string, wherein all characters in the encrypted character mapping table are used to generate the encryption part.
[0092] S1037. Obtain activity information, and obtain the fourth information corresponding to the activity department based on the activity information.
[0093] S1039. Obtain the fifth information corresponding to the verification unit based on the first information, the second information, the third information, and the fourth information.
[0094] If no further processing is performed, the first, second, third, fourth, and fifth pieces of information can be directly used as the information to be concatenated.
[0095] In a preferred embodiment, to further enhance the security of the resource identifier, the information corresponding to each component structure can be selectively transcoded. Specifically, the identifier structure also includes transcoding information, which includes at least one transcoding item. This transcoding item characterizes the transcoding requirements of the component structure corresponding to it. The step of extracting the component structures from the identifier structure information and obtaining the concatenation information corresponding to each component structure is as follows: Figure 6 As shown, it also includes:
[0096] S10311. Obtain all transcoding items in the transcoding information.
[0097] S10313. Transcode the information of the substructure corresponding to each transcoding item according to each transcoding item to obtain the information to be spliced corresponding to the substructure.
[0098] Specifically, the transcoding can be implemented based on number system conversion.
[0099] Specifically, the transcoding requirements in the transcoding item may include a mapping method and a mapping table. The mapping method is used to describe the relationship between the information of the substructure and the mapping table. The result of mapping the information of the substructure to the mapping table is used as the information to be spliced corresponding to the information of the substructure.
[0100] In another preferred embodiment, the information of the verification section can be generated based on the information of each section structure before transcoding, or it can be generated based on the concatenated information corresponding to each section structure after transcoding. For ease of description, in this embodiment of the invention, each piece of information used to generate the information of the verification section is referred to as input information, which can obviously be the information of the section structure or the concatenated information corresponding to the section structure. This embodiment of the invention provides a method for generating the information of the verification section, such as... Figure 7 As shown, it includes:
[0101] S1. Obtain all input information;
[0102] S3. Obtain the ASCII code value of each character in the input information according to the adjacency relationship of each input information.
[0103] S5. Sum the ASCII values of the characters in each input message to obtain the total sum.
[0104] S7. Take the modulo of the sum value relative to the total number of elements in the encrypted character mapping table to obtain the verification number.
[0105] S9. Use the content corresponding to the verification number in the encrypted character mapping table as the information of the verification unit.
[0106] S105. Obtain the separator based on the separator information.
[0107] Specifically, a delimiter mapping table can be maintained, and delimiters can be extracted from the delimiter mapping table based on the delimiter information.
[0108] S107. Based on the adjacency relationship of the substructures in the identifier structure information, connect the adjacent information to be spliced using the separator to obtain the resource identifier.
[0109] The resource identifiers generated in this embodiment of the invention include various information, such as service department information and activity department information. Based on this information, resource identifiers can be managed, and they can be indexed using the service department information and / or activity department information. In practical applications, different machines can generate and store resource identifiers independently. For applications with high performance requirements, they can be generated in large batches in advance. This is because the generation of resource identifiers in this embodiment of the invention does not rely on real-time information such as timestamps, and can be stored in shards based on business, machine, and single activity identifiers. The changing parts of the resource identifiers are used for indexing, which provides better write and query performance compared to the existing technology that simply uses string or numeric indexes without actual business meaning.
[0110] This invention discloses a resource identifier generation method. By following a resource identifier generation strategy, information about multiple substructures is obtained, and then information is concatenated based on delimiters to generate a resource identifier. This resource identifier generation method possesses at least the following advantages:
[0111] (1) In a distributed scenario, each server only needs to generate a resource identifier independently to ensure that the generated resource identifier is globally unique in the distributed system, thereby saving global management costs and reducing the difficulty of generating resource identifiers.
[0112] (2) The structure of each part of the resource identifier can be expanded arbitrarily, and the length of the resource identifier is not fixed, thus theoretically supporting the generation of resource identifiers of arbitrary granularity and length.
[0113] (3) The encryption of resource identifiers can improve the security of resource identifiers. Even if the resource identifier generation algorithm is leaked, the resource identifier cannot be directly reproduced, thus making the resource identifier secure to a certain extent. Therefore, it can be applied to scenarios with high requirements for resource identifiers.
[0114] (4) Resource identifiers can be transcoded or encrypted at the granularity of the substructure, thereby further improving the security of resource identifiers. Transcoding can also hide the plaintext information of the substructure, which is conducive to ensuring the information security of resource identifiers.
[0115] Corresponding to the resource identifier generation method, this embodiment of the invention also discloses a resource identifier verification method, such as... Figure 8 As shown, the verification method includes:
[0116] S201. Obtain a resource identifier and a resource identifier generation strategy corresponding to the resource identifier. The resource identifier generation strategy includes identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the substructure and the adjacency relationship of the substructure. The substructure includes at least a service substructure and a change substructure. The service substructure points to a service associated with the resource identifier, and the change substructure points to a field that ensures the resource identifier has uniqueness.
[0117] S203. Parse the resource identifier according to the resource identifier strategy to obtain the parsing results corresponding to each information section and the parsing results of the verification section. The information section is the other part structure in the resource identifier that is different from the verification section.
[0118] S205. Calculate the target verification information based on the parsing results corresponding to each information department.
[0119] The calculation method for the target verification information is the same as the method for generating the verification information in the resource identifier generation method, and will not be repeated here.
[0120] S207. If the target verification information is consistent with the parsing result of the verification unit, the verification passes.
[0121] The resource identifier verification method described in this embodiment of the invention is the inverse process of the resource identifier generation method described above, and the specific details will not be repeated here.
[0122] In a preferred embodiment, to prevent hackers from cracking resource identifiers through brute-force polling, the rate at which users submit resource verification requests can be limited, or a daily limit on the number of requests a user can make can be set.
[0123] The resource identifier generation method and corresponding resource identifier verification method disclosed in this invention can be widely applied to various distributed systems, thereby providing support for various cloud services. Examples of applicable scenarios are provided in this invention:
[0124] (1) It can be used to generate request serial numbers for various business systems.
[0125] As distributed systems grow larger, the number of services they can access also increases, and the complexity of their modules also increases. The requests required by each service can generate their corresponding resource identifiers based on the methods provided in this embodiment of the invention, and these identifiers can circulate and be shared within the distributed system.
[0126] For example, a purchase request in an in-game store involves modules such as the backend access layer, login authentication, character verification, balance inquiry, item quantity inquiry, balance deduction, and item distribution. Therefore, a globally unique request serial number is needed to identify each user's request and connect all the log records of each module in the complete request processing process. This request serial number is a kind of resource identifier.
[0127] (2) It can be used to generate transaction serial numbers in the payment field.
[0128] Taking games as an example again, from a single game to hundreds or thousands of business lines, commercialization will give rise to all kinds of malls and sales systems. Every user transaction needs a globally unique transaction serial number to mark the transaction and all related information, such as transaction amount, traded items, and transaction time. This transaction serial number is also a kind of resource identifier.
[0129] (3) Can be used to generate interactive identifiers
[0130] Taking chat rooms as an example, different front-end services are connected, and a large number of users are distributed in different chat rooms. Each user message needs to have a globally unique interaction identifier. The back-end needs to distribute messages based on this interaction identifier, which is a kind of resource identifier.
[0131] (4) Can be used to generate virtual item identifiers
[0132] With the rise of e-commerce, the trading of virtual items is also increasing. For example, redemption codes, red envelopes, vouchers, and electronic lottery tickets can all be understood as virtual items, and virtual item identifiers are a type of resource identifier.
[0133] As can be seen, the embodiments of the present invention can provide a globally unique, granular, and infinitely scalable resource identifier generation and verification method for distributed systems. It can be used for conventional resource identifier generation as well as for scenarios with high security requirements. Furthermore, it does not depend on existing distributed system components and does not require modification of the distributed system. It has low execution difficulty and cost, and has significant advantages in terms of strong feasibility.
[0134] This invention also provides a resource identifier generation device, such as... Figure 9 As shown, the device includes:
[0135] The resource identifier generation strategy acquisition module 301 is used to acquire a resource identifier generation strategy. The resource identifier generation strategy includes identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the substructure and the adjacency relationship of the substructure. The substructure includes at least a service substructure and a change substructure. The service substructure points to a service associated with the resource identifier, and the change substructure points to a field that ensures the resource identifier has uniqueness.
[0136] The component information generation module 303 is used to extract the sub-structures in the identifier structure information and obtain the component information to be spliced corresponding to each sub-structure;
[0137] Separator acquisition module 305 is used to acquire separators based on the separator information;
[0138] The resource identifier acquisition module 307 is used to obtain the resource identifier by connecting adjacent information to be spliced using the separator based on the adjacency relationship of the substructures in the identifier structure information.
[0139] Specifically, the resource identifier generation device disclosed in this embodiment of the invention is based on the same inventive concept as the method embodiment described above. For details, please refer to the method embodiment; further elaboration will not be repeated here.
[0140] This invention also provides a resource identifier verification device, such as... Figure 10 As shown, the device includes:
[0141] Resource identifier acquisition module 401 is used to acquire a resource identifier and a resource identifier generation strategy corresponding to the resource identifier. The resource identifier generation strategy includes identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the substructure and the adjacency relationship of the substructure. The substructure includes at least a service substructure and a change substructure. The service substructure points to a service associated with the resource identifier, and the change substructure points to a field that ensures the resource identifier has uniqueness.
[0142] The parsing module 403 is used to parse the resource identifier according to the resource identifier strategy to obtain the parsing results corresponding to each information section and the parsing results of the verification section. The information section is the other part structure in the resource identifier that is different from the verification section.
[0143] The target verification information calculation module 405 is used to calculate the target verification information based on the parsing results corresponding to each information section.
[0144] The verification module 407 is used to verify that if the target verification information is consistent with the parsing result of the verification unit, the verification passes.
[0145] Specifically, the resource identifier verification device disclosed in this embodiment of the invention is based on the same inventive concept as the method embodiment described above. For details, please refer to the method embodiment; further elaboration will not be repeated here.
[0146] This invention also provides a computer-readable storage medium that can store multiple instructions. These instructions are adaptable for loading and execution by a processor of the resource identifier generation method or resource identifier verification method described in this invention.
[0147] Furthermore, Figure 11 A schematic diagram of the hardware structure of a device for implementing the method provided in the embodiments of the present invention is shown. This device may participate in or include the apparatus or system provided in the embodiments of the present invention. Figure 11 As shown, device 10 may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 11 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, device 10 may also include a... Figure 11 The more or fewer components shown, or having the same Figure 11 The different configurations shown.
[0148] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the device 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0149] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method described in the embodiments of the present invention. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above-mentioned resource identifier generation method or resource identifier verification method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the device 10 via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0150] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of device 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a radio frequency (RF) module used for wireless communication with the Internet.
[0151] The display may be, for example, a touchscreen liquid crystal display (LCD) that allows a user to interact with the user interface of device 10 (or a mobile device).
[0152] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0153] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and server embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0154] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0155] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A resource identification processing method, characterized in that, The method includes: A resource identifier generation strategy is obtained, comprising identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the sub-structures and their adjacency relationships. The sub-structures include a service sub-structure, a variation sub-structure, an encryption sub-structure, and an activity sub-structure. The service sub-structure points to a service associated with a resource identifier. The activity sub-structure includes an activity identifier for characterizing activities at any multi-level granularity. The variation sub-structure is used to distinguish between resource identifiers generated for the same activity. The encryption sub-structure is plaintext used to pad the length of the resource identifier. The delimiter information allows the length of each sub-structure and the overall resource identifier to be flexible and expandable. The identifier corresponding to the delimiter information is an identifier not contained in the content corresponding to each sub-structure. Extract the substructure from the identified structure information; Based on the service identifier and the server identifier, the first information corresponding to the service unit is obtained. Once the first information is determined, the server independently performs the following operations: The second information corresponding to the changed part is obtained based on the auto_increment function in MySQL. Obtain the target length of the encryption part, and randomly select the target length number of characters from the encryption character mapping table to form the third information corresponding to the encryption part; The fourth information corresponding to the activity department is obtained based on the multi-level activity information; Obtain the separator based on the separator information; Based on the adjacency relationship of the substructures in the identifier structure information, the first information, the second information, the third information and the fourth information are connected by the separator to obtain the resource identifier, which does not include real-time information; The resource identifier is stored in fragments based on service, server, and single activity identifier; In the process of verifying the resource identifier, the rate at which users submit resource verification requests is limited, or a daily limit on the number of requests a user can make is set. The verification process is the reverse of the generation process.
2. The method according to claim 1, characterized in that, The resource identifier also includes a verification unit, and the server independently performs the following operations: The fifth information corresponding to the verification unit is obtained based on the first information, the second information, the third information, and the fourth information; Connecting the first information, the second information, the third information, and the fourth information with the separator includes connecting the first information, the second information, the third information, the fourth information, and the fifth information with the separator.
3. The method according to claim 1 or 2, characterized in that: The identifier structure also includes transcoding information, which includes at least one transcoding item. The transcoding item is used to characterize the transcoding requirements of the substructure corresponding to the transcoding item. The server also independently performs the following operations. Obtain all transcoding items from the transcoding information; The information corresponding to the substructure corresponding to each transcoding item is transcoded to obtain the information to be spliced corresponding to the substructure. Connecting the first information, the second information, the third information, and the fourth information using the separator includes connecting each of the information to be concatenated using the separator.
4. The method according to claim 2, characterized in that, The fifth piece of information is generated using the following method: Obtain each input information; The ASCII code values of the characters in each input information are obtained sequentially according to the adjacency relationship of each input information. The ASCII I code values of the characters in each input message are summed to obtain the total value. The verification number is obtained by taking the modulo of the sum value relative to the total number of elements in the encrypted character mapping table; The content corresponding to the verification number in the encrypted character mapping table is used as the fifth piece of information.
5. The method according to claim 2, characterized in that, During the verification of the resource identifier, the following operations are performed: Obtain the resource identifier and the resource identifier generation strategy; The resource identifier is parsed according to the resource identifier strategy to obtain the parsing results of each information section and the parsing results of the verification section. The information section is the other part structure in the resource identifier that is different from the verification section. Calculate the target verification information based on the parsing results corresponding to each information department; If the target verification information matches the parsing result of the verification unit, the verification passes.
6. A resource identification processing device, characterized in that, The device includes: A resource identifier generation strategy acquisition module is used to acquire a resource identifier generation strategy. The resource identifier generation strategy includes identifier structure information and delimiter information. The identifier structure information is used to characterize the information of the sub-structures and their adjacency relationships. The sub-structures include a service sub-structure, a variation sub-structure, an encryption sub-structure, and an activity sub-structure. The service sub-structure points to a service associated with a resource identifier. The activity sub-structure includes an activity identifier representing an activity at any multi-level granularity. The variation sub-structure is used to distinguish between resource identifiers generated for the same activity. The encryption sub-structure is plaintext used to pad the length of the resource identifier. The delimiter information allows the length of each sub-structure and the overall resource identifier to be flexible and expandable. The identifier corresponding to the delimiter information is an identifier not contained in the content corresponding to each sub-structure. The module for generating information to be concatenated is used to extract the substructure from the identifier structure information; obtain the first information corresponding to the service substructure based on the service identifier and the server identifier; when the first information is determined, the server independently performs the following operations: obtain the second information corresponding to the changing substructure based on MySQL's auto_increment; obtain the target length of the encryption substructure, randomly select the target length number of characters from the encryption character mapping table to form the third information corresponding to the encryption substructure; obtain the fourth information corresponding to the activity substructure based on multi-level activity information. A separator acquisition module is used to acquire separators based on the separator information; The resource identifier acquisition module is used to obtain a resource identifier by connecting the first information, the second information, the third information, and the fourth information with the separator according to the adjacency relationship of the substructure in the identifier structure information. The resource identifier does not include real-time information. In the process of verifying the resource identifier, the rate at which users submit resource verification requests is limited, or a daily limit on the number of requests a user can make is set. The verification process is the reverse of the generation process.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction or at least one program, which is loaded and executed by a processor to implement a resource identification processing method as described in any one of claims 1 to 5.
8. A resource identification processing device, characterized in that, The device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or at least one program being loaded and executed by the processor as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Security extensible Internet of Things identifier generation and analysis system
CN110266829A
Method and device for generating unique identifier
CN110928912A