CN113553518A - Resource identifier generation method, device, equipment and storage medium - Google Patents

Resource identifier generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN113553518A
CN113553518A CN202010330680.9A CN202010330680A CN113553518A CN 113553518 A CN113553518 A CN 113553518A CN 202010330680 A CN202010330680 A CN 202010330680A CN 113553518 A CN113553518 A CN 113553518A
Authority
CN
China
Prior art keywords
information
resource identifier
identifier
service
resource
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010330680.9A
Other languages
Chinese (zh)
Inventor
汪志伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Tencent Domain Computer Network Co Ltd
Original Assignee
Shenzhen Tencent Domain Computer Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Tencent Domain Computer Network Co Ltd filed Critical Shenzhen Tencent Domain Computer Network Co Ltd
Priority to CN202010330680.9A priority Critical patent/CN113553518A/en
Publication of CN113553518A publication Critical patent/CN113553518A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a resource identifier generation method, a device, equipment and a storage medium, wherein the generation method comprises the steps of acquiring a resource identifier generation strategy, the resource identifier generation strategy comprises identifier structure information and splitter information, the identifier structure information is used for representing the adjacency relation between part structure information and part structure information, the part structure at least comprises a service part and a change part, the service part points to the service for representing the relation with a resource identifier, and the change part points to a field for representing and ensuring the uniqueness of the resource identifier; extracting part structures in the identification structure information, and acquiring information to be spliced corresponding to each part structure; acquiring separators according to the separator information; and obtaining the resource identifier according to the adjacent relation of the part structures in the identifier structure information and the information to be spliced adjacent to the separator connecting part structure. The invention only needs to independently generate the resource identifier, and can ensure that the generated resource identifier is globally unique in the distributed system.

Description

Resource identifier generation method, device, equipment and storage medium
Technical Field
The present invention relates to the field of distributed computing, and in particular, to a method, an apparatus, a device, and a storage medium for generating a resource identifier.
Background
With the rise of the computing mode of cloud computing, a large number of computers can acquire computing power, storage space and information service which can be expanded theoretically wirelessly through cloud interaction, and the technical problem of how to ensure the uniqueness of resource identification in a distributed system supporting cloud computing is also brought while each computer realizes resource sharing through cloud interaction.
In order to ensure the uniqueness of the resource identifiers in the distributed system, various feasible schemes are provided in the prior art, such as utilizing a database self-increment identifier, generating an identifier by a server in combination with related parameters local to the server, or generating an identifier based on existing distributed components. However, in the prior art, excessive dependence on distributed components exists, or expansibility and flexibility are not strong, so that the applicability to scenes is not wide, and the application prospect is influenced to a certain extent.
Disclosure of Invention
The solutions capable of ensuring the uniqueness of the resource identifier in the prior art are both advantages and disadvantages, have their own application scenarios and limitations, and none of the solutions can generate the resource identifier capable of being expanded at will with high flexibility without depending on the existing switch components. Therefore, the embodiment of the invention provides a resource identifier generation method, a resource identifier generation device, a resource identifier generation apparatus and a storage medium.
In one aspect, the present invention provides a resource identifier generating method, where the method includes:
acquiring a resource identifier generation strategy, wherein the resource identifier generation strategy comprises identifier structure information and splitter information, the identifier structure information is used for representing the adjacency relation between part structure information and part structure, the part structure at least comprises a service part and a change part, the service part points to a field for representing and ensuring the uniqueness of the resource identifier, and the service part points to a service for representing the relation between the resource identifier and the resource identifier;
extracting part structures in the identification structure information, and acquiring information to be spliced corresponding to each part structure;
acquiring separators according to the separator information;
and obtaining the resource identifier according to the adjacent relation of the part structures in the identifier structure information and the information to be spliced adjacent to the separator connecting part structure.
In another aspect, the present invention provides a method for checking a resource identifier, where the method includes:
acquiring a resource identifier and a resource identifier generation strategy corresponding to the resource identifier, wherein the resource identifier generation strategy comprises identifier structure information and splitter information, the identifier structure information is used for representing the adjacency relation between part structure information and part structure, the part structure at least comprises a service part and a change part, the service part points to a field for representing the service associated with the resource identifier, and the change part points to the field for representing and ensuring the uniqueness of the resource identifier;
analyzing the resource identifier according to the resource identifier strategy to obtain an analysis result corresponding to each information part and an analysis result of a checking part, wherein the information part is the structure of other parts which are different from the checking part in the resource identifier;
calculating target verification information according to the analysis result corresponding to each information part;
and if the target verification information is consistent with the analysis result of the verification part, the verification is passed.
In another aspect, the present invention provides an apparatus for generating a resource identifier, where the apparatus includes:
a resource identifier generation policy acquisition module, configured to acquire a resource identifier generation policy, where the resource identifier generation policy includes identifier structure information and splitter information, where the identifier structure information is used to represent an adjacency relationship between part structure and information of a part structure, the part structure at least includes a service part and a change part, the service part is used to represent a service associated with a resource identifier, and the change part is used to represent a field for ensuring that the resource identifier has uniqueness;
the information to be spliced generation module is used for extracting the part structures in the identification structure information and acquiring the information to be spliced corresponding to each part structure;
the separator obtaining module is used for obtaining separators according to the separator information;
and the resource identifier obtaining module is used for obtaining the resource identifier according to the adjacency relation of the part structures in the identifier structure information and the information to be spliced adjacent to the separator connecting part structure.
In another aspect, the present invention provides an apparatus for verifying a resource identifier, where the apparatus includes:
a resource identifier obtaining module, configured to obtain a resource identifier and a resource identifier generation policy corresponding to the resource identifier, where the resource identifier generation policy includes identifier structure information and splitter information, the identifier structure information is used to represent an adjacency relation between part structure and information of a part structure, the part structure at least includes a service part and a change part, the service part is used to represent a service associated with the resource identifier, and the change part is used to represent a field for ensuring that the resource identifier has uniqueness;
the analysis module is used for analyzing the resource identifier according to the resource identifier strategy to obtain an analysis result corresponding to each information part and an analysis result of the checking part, wherein the information part is the structure of the other part which is different from the checking part in the resource identifier;
the target verification information calculation module is used for calculating target verification information according to the analysis result corresponding to each information part;
and the checking module is used for passing the checking if the target checking information is consistent with the analysis result of the checking part.
In another aspect, the present invention provides a computer-readable storage medium, where at least one instruction or at least one program is stored in the computer-readable storage medium, and the at least one instruction or the at least one program is loaded by a processor and executed to implement a resource identifier generation method or a resource identifier verification method as described above.
In another aspect, the present invention provides a resource identifier processing apparatus, which includes a processor and a memory, where the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded by the processor and executes the above resource identifier generating method or the above resource identifier verifying method.
The invention provides a resource identifier generation method, a resource identifier generation device, resource identifier generation equipment and a storage medium. According to the resource identifier generation method and the server, the information of a plurality of part structures is obtained according to the resource identifier generation strategy, and the resource identifier is generated based on the step of splicing the information by the separators, so that in a distributed scene, each server only needs to independently generate the resource identifier, the generated resource identifier can be ensured to be globally unique in a distributed system, the global management cost is saved, and the generation difficulty of the resource identifier is reduced. The structure of each part of the resource identifier can be expanded at will, and the length of the resource identifier is not fixedly limited, so that the generation of the resource identifier with any granularity and any length is supported theoretically.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a schematic diagram of an implementation environment of a resource identifier generation method provided by the present invention;
FIG. 2 is a flowchart of a resource identifier generation method provided by the present invention;
FIG. 3 is a schematic diagram of resource identification provided by the present invention;
fig. 4 is a flowchart of extracting partial structures in the identifier structure information to obtain information to be spliced corresponding to each partial structure according to the present invention;
FIG. 5 is a flow chart of obtaining an encrypted string according to a predetermined encryption algorithm according to the present invention;
fig. 6 is a flowchart for acquiring information to be spliced corresponding to each partial structure under transcoding conditions provided by the present invention;
FIG. 7 is a flow chart of an information generating method of a verification section according to the present invention;
FIG. 8 is a flow chart of a method for verifying a resource identifier provided by the present invention;
FIG. 9 is a block diagram of a resource identifier generation apparatus provided in the present invention;
FIG. 10 is a block diagram of a device for checking a resource identifier according to the present invention;
fig. 11 is a hardware structural diagram of an apparatus for implementing the method provided by the embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In order to make the objects, technical solutions and advantages disclosed in the embodiments of the present invention more clearly apparent, the embodiments of the present invention are described in further detail below with reference to the accompanying drawings and the embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the embodiments of the invention and are not intended to limit the embodiments of the invention.
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present embodiment, "a plurality" means two or more unless otherwise specified. In order to facilitate understanding of the technical solutions and the technical effects thereof described in the embodiments of the present invention, the embodiments of the present invention first explain related terms:
MySQL: a relational database management system.
Redis: namely, Remote Dictionary service (Remote Dictionary Server), is an open-source network-supporting, memory-based and persistent log-type, Key-Value database, and provides application program interfaces of multiple languages.
Twitter snowfall algorithm: is a Twitter open source distributed identity generation algorithm.
Zookeeper: is a distributed, open source distributed application coordination service.
Carrying out binary conversion: and converting the numerical values based on different mathematical systems to obtain different display results, wherein the higher the used system is, the fewer the required digits are.
ASCII code: american Standard Code for Information exchange Code, United states Information exchange Standard Code. The computer coding system is based on Latin letters and is mainly used for displaying modern English and other Western European languages.
Cloud Computing (Cloud Computing) refers to obtaining required resources in an on-demand, easily-extensible manner over a network; the generalized cloud computing refers to a delivery and use mode of a service, and refers to obtaining a required service in an on-demand and easily-extensible manner through a network. Such services may be IT and software, internet related, or other services. Cloud Computing is a product of development and fusion of traditional computers and Network Technologies, such as Grid Computing (Grid Computing), distributed Computing (distributed Computing), Parallel Computing (Parallel Computing), Utility Computing (Utility Computing), Network Storage (Network Storage Technologies), Virtualization (Virtualization), Load balancing (Load Balance), and the like.
With the development of diversification of internet, real-time data stream and connecting equipment and the promotion of demands of search service, social network, mobile commerce, open collaboration and the like, cloud computing is rapidly developed. Different from the prior parallel distributed computing, the generation of cloud computing can promote the revolutionary change of the whole internet mode and the enterprise management mode in concept.
In order to generate a unique resource identifier in a distributed system supporting cloud computing, the prior art provides several feasible solutions:
(1) self-increment identification by using database
The auto _ increment field of MySQL is used for realizing the self-increment identification, or the Redis is used for realizing the self-increment identification, and different step lengths can be set for different application scenes to generate the unique identification. The unique and ordered generated identification can be ensured by utilizing the self-increment identification of the database, and the use method is simple; but it requires independent deployment of databases or Redis instances, is costly to use, and has performance bottlenecks.
(2) Generating, by a server, an identity in combination with related parameters local to the server
The unique identifier can be obtained by the server through calculation by combining the local network card address, the local time and the random number. The server can generate the identifier locally in the server by combining the local related parameters of the server, the use method is simple, the performance is good, and the distributed application scene is met; however, the identifier generated by the scheme has a fixed format and a long length, occupies a large storage space, and is disordered and unreadable.
(3) Twitter snowfly algorithm
The identifier generated by the Twitter snowfall algorithm is fixed to 64 bits and comprises four fields: 1-bit sign bit, 41-bit timestamp difference, 10-bit machine number and self-increment identification within 12-bit millisecond. The uniqueness of the identification in a distributed scene can be ensured, the generation performance is high, and the identification is ordered according to time; however, this solution requires independent development and deployment, depends on the server local time, and has an upper limit on the size of unique identifiers that can be supported because of the length constraints of the timestamp difference and the machine number field.
(4) Generating an identity based on existing open source components supporting distributed systems
The identification is generated by relying on the components such as the database, the Zookeeper and the like, so that the resource identification obtained in a distributed scene is ensured to be globally unique and monotonically increased, and the safety is high.
The solutions capable of ensuring the uniqueness of the resource identifier in the prior art are both advantages and disadvantages, have their own application scenarios and limitations, and none of the solutions can generate the resource identifier capable of being expanded at will with high flexibility without depending on the existing switch components. To this end, an embodiment of the present invention provides a resource identifier generating method, which aims to provide a solution for generating a resource identifier:
(1) the method has good expansibility, can be applied to different application scenes, can ensure the overall increasing trend of the distributed generation of the resource identifiers, is globally unique, and can index the resource identifiers generated in different applications to corresponding services;
(2) the information security of the unique resource identifier can be guaranteed, a user cannot acquire any connotation information from the resource identifier, so that the resource identifier cannot be forged, even if an algorithm for generating the resource identifier is leaked, the generated resource identifier cannot be directly reproduced through the algorithm, and violent polling is still required, so that the cracking difficulty is improved.
(3) And each resource identifier can be subjected to validity check, and the execution efficiency is better.
First, the embodiment of the present invention discloses an implementation environment of the resource identifier generation method in a possible embodiment.
Referring to fig. 1, the implementation environment includes: at least one client 01 and a server 03.
The client 01 may be an entity device for interacting with the server 03, and the client 01 may further include software running in the entity device, for example, a related program that runs to obtain a service provided by the server 03 and interacts with the server 03. The Client 01 may be communicatively connected to the Server 03 based on a Browser/Server mode (Browser/Server, B/S) or a Client/Server mode C/S (Client/Server, C/S).
The server 03 may be a distributed server or any one server in a server cluster composed of a plurality of servers. The server 03 supports cloud computing in a distributed architecture and provides cloud services. Any one of the servers 03 may independently run the resource identifier generation method to obtain a resource identifier that has uniqueness and can index to a service provided by the server.
An embodiment of the present invention provides a resource identifier generating method, as shown in fig. 2, where the method may be run in a server in a distributed system, and the method includes:
s101, a resource identification generation strategy is obtained, wherein the resource identification generation strategy comprises identification structure information and splitter information, the identification structure information is used for representing the adjacency relation between the information of a part structure and the part structure, the part structure at least comprises a service part and a change part, the service part points to the service used for representing the relation between the service and the resource identification, and the change part points to a field used for representing and ensuring the uniqueness of the resource identification.
The resource identifier generated in the embodiment of the present invention may be configured by a plurality of part structures, and the content and the proximity relation of each part structure are recorded in the identifier structure information, and the resource identifier at least includes a service part and a change part. The service part points to a service associated with a resource identifier, the resource identifier is required to be used in the service or the service is used for generating the resource identifier, so that the service can be indexed to according to the resource identifier, and the resource identifiers corresponding to different services in a distributed system can be ensured to be different, which is a necessary condition for ensuring the uniqueness of the resource identifier. The change part points to the changed field in the resource identification, and even if the resource identification is generated by the same server based on the same service, the content of the field pointed by the change part is necessarily different, so that the uniqueness of the resource identification is ensured.
As shown in fig. 3, it shows a resource identifier in a possible embodiment, the resource identifier is composed of a service part, an encryption part, an activity part and a change part, and the contents of the service part, the encryption part, the activity part and the change part are sequentially spliced by separators to obtain the resource identifier. Specifically, the contents of the respective sections are as follows:
a service part: the resource identifier is generated for the service corresponding to the service field by the machine corresponding to the machine number. The service part is arranged so that the resource identifier generation method provided by the embodiment can support the expansion of each service and each machine, and after different numbers are allocated to different services and machines, the resource identifier generation method can be independently implemented.
An encryption unit: when the length of the resource identifier is required, the length can be supplemented by arranging an encryption part, and the encryption part can be generated by using an encryption algorithm to enhance the safety of the resource identifier, and even if the resource identifier generation algorithm is leaked, the resource identifier cannot be directly reproduced. The encryption unit may be configured by a random string. The encryption unit itself may be a ciphertext or a plaintext. The encryption part is arranged to supplement the length of the resource identifier and improve the cracking difficulty of the resource identifier.
A movable part: the setting of the activity part is extensible, which can make the generation of the resource identifier meet any granularity requirement, the activity part may include at least one level of activity identifier, the activity identifier may also be a multi-level identifier, and the more the number of levels of the activity identifier, the smaller the granularity. The resource identifier generation method in the embodiment of the invention can support the resource identifier generation of single-service single-machine single-activity granularity and the resource identifier generation of activities of any granularity, so that the resource identifiers can be generated according to batches.
A changing part: the change part is related to the activity part and is used for distinguishing the resource identifiers generated aiming at the same activity, and the change part can be generated by setting a step length and carrying out a self-increment rule.
In a preferred embodiment, in order to facilitate checking the resource identifier, the resource identifier may further include a checking portion, and the checking portion may be attached to a tail portion or other designated position of the resource identifier.
The purpose of dividing each part structure by a separator in the resource identifier is to make the length of the content corresponding to each part structure free and not fixed, and to make the resource identifier expandable, and the length of each part structure and the overall length of the resource identifier can be changed as needed. In a preferred embodiment, the identifier corresponding to the separator is an identifier not included in the content corresponding to each part structure, so that the separation function can be achieved.
In fig. 3, "EB" is a service section, "HB" is an encryption section, "4U" is an active section, "HBT" is a change section, "8" is a verification section, and "Z" is a delimiter.
And S103, extracting the part structures in the identification structure information, and acquiring the information to be spliced corresponding to each part structure.
Specifically, the extracting a partial structure in the identification structure information and obtaining information to be spliced corresponding to each partial structure, as shown in fig. 4, includes:
and S1031, acquiring a service identifier pointed by the resource identifier and a server identifier of the server, and acquiring first information corresponding to the service part according to the service identifier and the server identifier.
S1033, obtaining second information corresponding to the change part based on a local self-increment algorithm.
Different from a self-increment algorithm for generating the identifier in the distributed system in the prior art, the self-increment algorithm in the prior art must ensure that the identifier is self-incremented in the global state of the distributed system, and the generated identifier can be ensured to have uniqueness in the distributed system. In the embodiment of the invention, the change part is generated only by the local self-increment of the server without considering other servers or other components in the distributed system, and because the service parts of the resource identifiers generated by different servers are different, the whole pressure for distinguishing the resource identifiers is not required to be concentrated in the change part, so the change part is obtained only based on the local self-increment algorithm of the server, and the difficulty of the self-increment algorithm is obviously greatly reduced compared with the prior art. The server local autonomic algorithm can be implemented based on the prior art, and the embodiment of the invention does not limit the specific implementation means.
In particular, the server local auto-increment algorithm can be implemented using existing database auto-increment algorithms, such as auto _ increment field of MySQL or Redis. Because the self-increment in the embodiment of the invention does not need to consider the whole situation, and only needs to ensure the self-increment of the change part of the resource identifier in a single server, the parallel capacity expansion can be supported, and the single-point performance bottleneck can not occur.
In a preferred embodiment, the identification structure information further includes an encryption portion, a movable portion, and a verification portion, the extracting a partial structure in the identification structure information to obtain information to be spliced corresponding to each partial structure further includes:
and S1035, obtaining an encryption character string according to a preset encryption algorithm, and taking the encryption character string as third information corresponding to the encryption part.
In a possible embodiment, the obtaining of the encrypted string according to the preset encryption algorithm, as shown in fig. 5, includes:
s10351, a target length of the encryption unit is acquired.
Specifically, the target length can be determined according to actual requirements, and can be flexibly increased and decreased.
And S10353, randomly selecting characters with target length quantity in an encryption character mapping table to form an encryption character string, wherein the characters in the encryption character mapping table are all used for generating an encryption part.
S1037, activity information is obtained, and fourth information corresponding to the activity portion is obtained according to the activity information.
S1039, obtaining fifth information corresponding to the verification part according to the first information, the second information, the third information and the fourth information.
If the subsequent processing is not performed, the first information, the second information, the third information, the fourth information and the fifth information can be directly used as the information to be spliced.
In a preferred embodiment, to further increase the security of the resource identifier, the information corresponding to each partial structure may be optionally transcoded. Specifically, the identification structure further includes transcoding information, where the transcoding information includes at least one transcoding item, where the transcoding item is used to represent a transcoding requirement of a partial structure corresponding to the transcoding item, the partial structure in the identification structure information is extracted, and information to be spliced corresponding to each partial structure is obtained, as shown in fig. 6, the method further includes:
and S10311, obtaining all transcoding items in the transcoding information.
And S10313, transcoding the information of the partial structure corresponding to the transcoding item according to each transcoding item to obtain the information to be spliced corresponding to the partial structure.
In particular, the transcoding may be implemented based on a binary conversion.
Specifically, the transcoding requirement in the transcoding item may include a mapping method and a mapping table, where the mapping method is used to describe a relationship between the information of the partial structure and the mapping table, and a result obtained by mapping the information of the partial structure to the mapping table is used as the information to be spliced corresponding to the information of the partial structure.
In another preferred embodiment, the information of the verification portion may be generated based on information of each partial structure before transcoding, or may be generated based on information to be spliced corresponding to each partial structure after transcoding. For convenience of description, in the embodiment of the present invention, each piece of information used for generating the information of the verification portion is referred to as input information, and the input information may be information of a partial structure or information to be spliced corresponding to the partial structure. An embodiment of the present invention provides an information generating method of a verification portion, as shown in fig. 7, including:
s1, acquiring each input information;
and S3, sequentially obtaining the ASCII code values of the characters of the input information according to the adjacency relation of the input information.
And S5, accumulating and summing the obtained ASCII code values of the characters of each input message to obtain a sum value.
And S7, taking a module of the total sum value relative to the total number of elements in the encrypted character mapping table to obtain a check number.
And S9, taking the content corresponding to the check number in the encrypted character mapping table as the information of the check part.
And S105, acquiring the separator according to the separator information.
Specifically, a separator mapping table may be maintained, and separators may be extracted from the separator mapping table according to the separator information.
And S107, obtaining resource identification according to the adjacent relation of the part structures in the identification structure information and the information to be spliced adjacent to the separator connecting part structure.
The resource identifier generated by the embodiment of the invention comprises various information, such as information of the service part and information of the activity part, the resource identifier can be managed based on the information, and the resource identifier can be indexed through the information of the service part and/or the information of the activity part. In practical application, different machines can generate and store the resource identifier independently, and for application with higher performance requirements, the resource identifier can be generated in advance in large batch, because the resource identifier in the embodiment of the invention is generated without depending on real-time information such as a time stamp and the like, the resource identifier can be stored in a fragmentation mode based on business, machines and single-activity identifiers, and the change part in the resource identifier is used for indexing, so that better writing and query performance can be achieved compared with the prior art which simply uses a character string index or a numerical index without actual business meaning.
The embodiment of the invention discloses a resource identifier generation method, which obtains information of a plurality of partial structures according to a resource identifier generation strategy and generates a resource identifier based on a step of splicing the information by separators, so that the resource identifier generation method at least has the following advantages:
(1) in a distributed scene, each server only needs to independently generate a resource identifier, so that the generated resource identifier can be ensured to be globally unique in a distributed system, the global management cost is saved, and the generation difficulty of the resource identifier is reduced.
(2) The structure of each part of the resource identifier can be expanded at will, and the length of the resource identifier is not fixedly limited, so that the generation of the resource identifier with any granularity and any length is supported theoretically.
(3) The resource identifier is provided with the encryption part, so that the security of the resource identifier can be improved, and even if the resource identifier generation algorithm is leaked, the resource identifier cannot be directly reproduced, so that the resource identifier is also safe to a certain extent, and therefore, the resource identifier can be applied to scenes with higher requirements on the resource identifier.
(4) The resource identifier can be transcoded or encrypted at the granularity of the partial structure, so that the safety of the resource identifier is further improved, and the plaintext information of the partial structure can be hidden through transcoding, thereby being beneficial to ensuring the information safety of the resource identifier.
Corresponding to the resource identifier generation method, the embodiment of the present invention further discloses a verification method for the resource identifier, as shown in fig. 8, where the verification method includes:
s201, resource identification and a resource identification generation strategy corresponding to the resource identification are obtained, the resource identification generation strategy comprises identification structure information and splitter information, the identification structure information is used for representing the adjacency relation between the part structure and the part structure, the part structure at least comprises a service part and a change part, the service part points to the service used for representing the relation between the part structure and the resource identification, and the change part points to a field used for representing and ensuring the uniqueness of the resource identification.
S203, analyzing the resource identification according to the resource identification strategy to obtain an analysis result corresponding to each information part and an analysis result of the checking part, wherein the information part is the structure of other parts different from the checking part in the resource identification.
And S205, calculating target verification information according to the analysis result corresponding to each information part.
The calculation method of the target check information is consistent with the generation method of the information of the check part in the generation method of the resource identifier, and is not described herein again.
And S207, if the target verification information is consistent with the analysis result of the verification part, the verification is passed.
The method for verifying the resource identifier according to the embodiment of the present invention and the method for generating the resource identifier are inverse processes, and details are not repeated here.
In a preferred embodiment, in order to avoid a hacker from cracking the resource identifier by means of brute force polling, the resource check request submission rate of the user may be limited, or an upper limit on the number of requests per day of the user may be set.
The resource identifier generation method and the corresponding resource identifier verification method disclosed by the embodiment of the invention can be widely applied to various distributed systems, so as to provide support for various cloud services, and the embodiment of the invention exemplifies the applicable scenes:
(1) can be used for generating request serial numbers of various business systems
Along with the increasing scale of the distributed system, the accessible services are more and more, the module complexity is higher and more, and the request required by each service can generate the corresponding resource identifier based on the method provided by the embodiment of the invention and can be circulated and shared in the distributed system.
For example: a shopping request of a mall in a game relates to modules such as a background access layer, login authentication, role verification, balance inquiry, prop quantity limit inquiry, balance deduction, prop issuing and the like, so that a globally unique request serial number is needed to identify each request of a user, all log records passing through each module are recorded in a complete request processing process in series, and the request serial number is a resource identifier.
(2) Can be used for generating transaction serial numbers in the payment field
Still taking a game as an example, from a single game to hundreds of business lines, commercialization can bring up a variety of shopping malls and selling systems, each user transaction requires a globally unique transaction serial number to mark the transaction and all associated information, such as transaction amount, transaction article, transaction time, etc., and the transaction serial number is also a resource identifier.
(3) Can be used for generating interactive identification number
Taking a chat room as an example, different services at the front end are accessed, a large number of users are distributed in different chat rooms, each user message needs to have a globally unique interactive identification number, the background needs to distribute the messages according to the interactive identification number, and the interactive identification number is a resource identification.
(4) Can be used for generating virtual article identification
With the rise of electronic commerce, virtual article transactions are increasing, such as exchange codes, red packages, vouchers, and electronic lottery tickets can be understood as virtual articles, and virtual article identifiers are resource identifiers.
Therefore, the embodiment of the invention can provide a resource identifier generation and verification method which is globally unique, adjustable in granularity and infinitely extensible for the distributed system, can be used for conventional resource identifier generation, can also be suitable for related scenes with high safety requirements, does not depend on related components of the existing distributed system, does not need to modify the distributed system, is low in execution difficulty and cost, and has the remarkable advantage of strong feasibility.
An embodiment of the present invention further provides a resource identifier generating apparatus, as shown in fig. 9, the apparatus includes:
a resource identifier generation policy obtaining module 301, configured to obtain a resource identifier generation policy, where the resource identifier generation policy includes identifier structure information and splitter information, where the identifier structure information is used to represent an adjacency relationship between information of a part structure and the part structure, the part structure includes at least a service part and a change part, the service part is used to represent a service associated with a resource identifier, and the change part is used to represent a field for ensuring that the resource identifier has uniqueness;
a to-be-spliced information generating module 303, configured to extract the partial structures in the identification structure information, and obtain to-be-spliced information corresponding to each partial structure;
a separator obtaining module 305, configured to obtain separators according to the separator information;
and a resource identifier obtaining module 307, configured to obtain a resource identifier according to the adjacency relation of the partial structures in the identifier structure information, by using the information to be spliced, where the separator connection portion structures are adjacent to each other.
Specifically, the embodiment of the invention discloses a resource identifier generation device and the embodiment of the method, which are all based on the same inventive concept. For details, please refer to the method embodiment, which is not described herein.
An embodiment of the present invention further provides a device for verifying a resource identifier, as shown in fig. 10, where the device includes:
a resource identifier obtaining module 401, configured to obtain a resource identifier and a resource identifier generating policy corresponding to the resource identifier, where the resource identifier generating policy includes identifier structure information and splitter information, the identifier structure information is used to represent an adjacency relation between part structure and information of a part structure, the part structure at least includes a service part and a change part, the service part is used to represent a service associated with the resource identifier, and the change part is used to represent a field for ensuring that the resource identifier has uniqueness;
an analysis module 403, configured to analyze the resource identifier according to the resource identifier policy to obtain an analysis result corresponding to each information portion and an analysis result of the verification portion, where the information portion is a structure of another portion different from the verification portion in the resource identifier;
a target verification information calculation module 405, configured to calculate target verification information according to analysis results corresponding to the information portions;
a checking module 407, configured to pass the checking if the target checking information is consistent with the analysis result of the checking part.
Specifically, the embodiment of the invention discloses a device for checking a resource identifier, which is based on the same inventive concept as the embodiment of the method. For details, please refer to the method embodiment, which is not described herein.
An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium may store a plurality of instructions. The instructions may be adapted to be loaded by a processor and perform a resource identifier generation method or a resource identifier verification method according to an embodiment of the present invention.
Further, fig. 11 shows a hardware structure diagram of an apparatus for implementing the method provided by the embodiment of the present invention, and the apparatus may participate in forming or containing the device or system provided by the embodiment of the present invention. As shown in fig. 11, the device 10 may include one or more (shown as 102a, 102b, … …, 102 n) processors 102 (the processors 102 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. Besides, the method can also comprise the following steps: 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 source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 11 is only an illustration and is not intended to limit the structure of the electronic device. For example, device 10 may also include more or fewer components than shown in FIG. 11, or have a different configuration than shown in FIG. 11.
It should be noted that the one or more processors 102 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuitry may be a single, stand-alone processing module, or incorporated in whole or in part into any of the other elements in the device 10 (or mobile device). As referred to in the embodiments of the application, the data processing circuit acts as a processor control (e.g. selection of a variable resistance termination path connected to the interface).
The memory 104 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the methods described in the embodiments of the present invention, and the processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 104, that is, implementing one resource identifier generation method or one resource identifier verification method described above. 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 examples, memory 104 may further include memory located remotely from processor 102, which may be connected to device 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of such networks may include wireless networks provided by the communication provider of the device 10. In one example, the transmission device 106 includes a network adapter (NIC) that can be connected to other network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the device 10 (or mobile device).
It should be noted that: the precedence order of the above embodiments of the present invention is only for description, and does not represent the merits of the embodiments. And specific embodiments thereof have been described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the device and server embodiments, since they are substantially similar to the method embodiments, the description is simple, and the relevant points can be referred to the partial description of the method embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. A resource identifier generation method, the method comprising:
acquiring a resource identifier generation strategy, wherein the resource identifier generation strategy comprises identifier structure information and splitter information, the identifier structure information is used for representing the adjacency relation between part structure information and part structure, the part structure at least comprises a service part and a change part, the service part points to a field for representing and ensuring the uniqueness of the resource identifier, and the service part points to a service for representing the relation between the resource identifier and the resource identifier;
extracting part structures in the identification structure information, and acquiring information to be spliced corresponding to each part structure;
acquiring separators according to the separator information;
and obtaining the resource identifier according to the adjacent relation of the part structures in the identifier structure information and the information to be spliced adjacent to the separator connecting part structure.
2. The method according to claim 1, wherein the extracting partial structures in the identification structure information and obtaining information to be spliced corresponding to each partial structure comprises:
acquiring a service identifier pointed by the resource identifier and a server identifier of the server, and acquiring first information corresponding to a service part according to the service identifier and the server identifier;
and obtaining second information corresponding to the change part based on a local auto-increment algorithm.
3. The method according to claim 1, wherein the resource identifier includes a service portion, an encryption portion, an activity portion, a change portion, and a verification portion, and the extracting the partial structures in the identifier structure information to obtain the information to be spliced corresponding to each partial structure includes:
acquiring a service identifier pointed by the resource identifier and a server identifier of the server, and acquiring first information corresponding to a service part according to the service identifier and the server identifier;
obtaining second information corresponding to the change part based on a local self-increment algorithm;
obtaining an encryption character string according to a preset encryption algorithm, and taking the encryption character string as third information corresponding to the encryption part;
acquiring activity information, and acquiring fourth information corresponding to the activity part according to the activity information;
and obtaining fifth information corresponding to the verification part according to the first information, the second information, the third information and the fourth information.
4. A method according to claim 2 or 3, characterized in that:
the identification structure further comprises transcoding information, wherein the transcoding information comprises at least one transcoding item, and the transcoding item is used for representing the transcoding requirement of the partial structure corresponding to the transcoding item; extracting the part structures in the identification structure information, and acquiring information to be spliced corresponding to each part structure;
acquiring all transcoding items in the transcoding information;
and transcoding the information of the part structure corresponding to the transcoding item according to each transcoding item to obtain the information to be spliced corresponding to the part structure.
5. The method according to claim 2 or 3, wherein the resource identifier further comprises a check part, and information of the check part is generated by the following method:
acquiring each input information;
sequentially obtaining ASCI I code values of characters of the input information according to the adjacency relation of the input information;
accumulating and summing the obtained ASCII code values of the characters of each input message to obtain a sum value;
the sum value is modulo relative to the total number of elements in the encrypted character mapping table to obtain a check number;
and taking the content corresponding to the check number in the encrypted character mapping table as the information of the check part.
6. A method for checking resource identifiers, the method comprising:
acquiring a resource identifier and a resource identifier generation strategy corresponding to the resource identifier, wherein the resource identifier generation strategy comprises identifier structure information and splitter information, the identifier structure information is used for representing the adjacency relation between part structure information and part structure, the part structure at least comprises a service part and a change part, the service part points to a field for representing the service associated with the resource identifier, and the change part points to the field for representing and ensuring the uniqueness of the resource identifier;
analyzing the resource identifier according to the resource identifier strategy to obtain an analysis result corresponding to each information part and an analysis result of a checking part, wherein the information part is the structure of other parts which are different from the checking part in the resource identifier;
calculating target verification information according to the analysis result corresponding to each information part;
and if the target verification information is consistent with the analysis result of the verification part, the verification is passed.
7. An apparatus for generating a resource identifier, the apparatus comprising:
a resource identifier generation policy acquisition module, configured to acquire a resource identifier generation policy, where the resource identifier generation policy includes identifier structure information and splitter information, where the identifier structure information is used to represent an adjacency relationship between part structure and information of a part structure, the part structure at least includes a service part and a change part, the service part is used to represent a service associated with a resource identifier, and the change part is used to represent a field for ensuring that the resource identifier has uniqueness;
the information to be spliced generation module is used for extracting the part structures in the identification structure information and acquiring the information to be spliced corresponding to each part structure;
the separator obtaining module is used for obtaining separators according to the separator information;
and the resource identifier obtaining module is used for obtaining the resource identifier according to the adjacency relation of the part structures in the identifier structure information and the information to be spliced adjacent to the separator connecting part structure.
8. An apparatus for verifying a resource identifier, the apparatus comprising:
a resource identifier obtaining module, configured to obtain a resource identifier and a resource identifier generation policy corresponding to the resource identifier, where the resource identifier generation policy includes identifier structure information and splitter information, the identifier structure information is used to represent an adjacency relation between part structure and information of a part structure, the part structure at least includes a service part and a change part, the service part is used to represent a service associated with the resource identifier, and the change part is used to represent a field for ensuring that the resource identifier has uniqueness;
the analysis module is used for analyzing the resource identifier according to the resource identifier strategy to obtain an analysis result corresponding to each information part and an analysis result of the checking part, wherein the information part is the structure of the other part which is different from the checking part in the resource identifier;
the target verification information calculation module is used for calculating target verification information according to the analysis result corresponding to each information part;
and the checking module is used for passing the checking if the target checking information is consistent with the analysis result of the checking part.
9. A computer-readable storage medium, in which at least one instruction or at least one program is stored, and the at least one instruction or the at least one program is loaded and executed by a processor to implement a resource identifier generation method according to claim 1 or a resource identifier verification method according to claim 6.
10. A resource identifier processing device, characterized in that the device comprises a processor and a memory, wherein at least one instruction or at least one program is stored in the memory, and the at least one instruction or the at least one program is loaded by the processor and executes a resource identifier generating method according to claim 1 or a resource identifier checking method according to claim 6.
CN202010330680.9A 2020-04-24 2020-04-24 Resource identifier generation method, device, equipment and storage medium Pending CN113553518A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010330680.9A CN113553518A (en) 2020-04-24 2020-04-24 Resource identifier generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010330680.9A CN113553518A (en) 2020-04-24 2020-04-24 Resource identifier generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113553518A true CN113553518A (en) 2021-10-26

Family

ID=78129519

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010330680.9A Pending CN113553518A (en) 2020-04-24 2020-04-24 Resource identifier generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113553518A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115361399A (en) * 2022-10-24 2022-11-18 中国水利水电第七工程局有限公司 Multi-terminal data synchronization method, device and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115361399A (en) * 2022-10-24 2022-11-18 中国水利水电第七工程局有限公司 Multi-terminal data synchronization method, device and system

Similar Documents

Publication Publication Date Title
EP3832578A1 (en) Electronic invoice identifier allocation method, and electronic ticket generating method, device and system
TWI743458B (en) Method, device and system for parallel execution of blockchain transactions
CN110019125B (en) Database management method and device
CN111182025B (en) Message processing method, device, server and storage medium
CN107229619B (en) Method and device for counting and displaying calling condition of internet service link
JP6716727B2 (en) Streaming data distributed processing method and apparatus
US20160275603A1 (en) Service processing method, device, and terminal
CN111611305A (en) Data processing method, device and medium
CN111611249A (en) Data management method, device, equipment and storage medium
CN104579909A (en) Method and equipment for classifying user information and acquiring user grouping information
CN111163130A (en) Network service system and data transmission method thereof
CN111881329A (en) Account balance management method and system
CN109558710B (en) User login method, device, system and storage medium
CN111339743A (en) Account generating method and device
CN113553518A (en) Resource identifier generation method, device, equipment and storage medium
CN106487653B (en) Message processing method and server
CN116703071A (en) Resource sharing method, device and equipment and storage medium
CN106708869B (en) Group data processing method and device
CN111555894A (en) Data processing method, device, equipment and storage medium
CN108667647B (en) Method and device for setting device parameters and server
EP4287102A1 (en) Cross-chain transaction processing method and apparatus, electronic device, and storage medium
CN113420050A (en) Data query management method and device, computer equipment and readable storage medium
CN113449042A (en) Automatic data warehouse-dividing method and device
CN113487411A (en) Method, device, equipment and computer readable medium for information interaction
CN111726266A (en) Hot spot data barreling method and system and computer equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination