CN111416879A - Method, device and equipment for generating unique ID with signature and storage medium - Google Patents

Method, device and equipment for generating unique ID with signature and storage medium Download PDF

Info

Publication number
CN111416879A
CN111416879A CN201910007475.6A CN201910007475A CN111416879A CN 111416879 A CN111416879 A CN 111416879A CN 201910007475 A CN201910007475 A CN 201910007475A CN 111416879 A CN111416879 A CN 111416879A
Authority
CN
China
Prior art keywords
signature
generating
time
unique
variable
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
CN201910007475.6A
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.)
Aspire Digital Technologies Shenzhen Co Ltd
Original Assignee
Aspire Digital Technologies Shenzhen 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 Aspire Digital Technologies Shenzhen Co Ltd filed Critical Aspire Digital Technologies Shenzhen Co Ltd
Priority to CN201910007475.6A priority Critical patent/CN111416879A/en
Publication of CN111416879A publication Critical patent/CN111416879A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/30Managing network names, e.g. use of aliases or nicknames
    • H04L61/3015Name registration, generation or assignment

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

The invention discloses a method for generating a unique ID with a signature, which comprises the following steps: acquiring current system time and generating a time ID; generating a sequence number by Redis; generating a signature according to a preset signature rule; combining the time ID, the serial number, and the signature to generate a unique ID. The invention also discloses a device, equipment and storage medium for generating the unique ID with the signature. The invention relates to the technical field of computer software, in particular to a method, a device, equipment and a storage medium for generating a unique ID with a signature.

Description

Method, device and equipment for generating unique ID with signature and storage medium
Technical Field
The invention relates to the technical field of computer software, in particular to a method, a device, equipment and a storage medium for generating a unique ID with a signature.
Background
The unique ID is an ID generated by a certain method and according to a certain rule, and the main characteristic is uniqueness. The use of unique IDs is quite widespread. There are many ways to generate IDs, which can be adapted to different scenarios, requirements and performance requirements. The existing methods for generating a unique ID include four methods:
(1) generating an ID through a self-growing field or sequence of a database;
(2)UUID;
(3) generating an ID through a snowfall algorithm of Twitter;
(4) object ID of MongoDB.
Aiming at the first method, different databases have different implementation modes, the migration cost is too high, the realization of database division and table division is complex, and the expansibility is poor; aiming at the second method, generated ID meaning letters and the like must be stored by using character strings, the query performance is low, the IDs are unordered, and the storage space occupied by the IDs is large; for the third method, generation services of the ID and clocks dependent on each service need to be deployed independently; for the fourth method, the generated ID is a hexadecimal character string, which affects the query efficiency.
In addition, the above four ID generation methods have no signature, and any user request needs to be queried in a cache or a database to verify whether the ID is a real and valid ID, so that the response time of the interface is increased, and the stability of the system is affected.
Disclosure of Invention
The present invention is directed to solving, at least to some extent, one of the technical problems in the related art. Therefore, an object of the present invention is to provide a method, an apparatus, a device and a storage medium for generating a unique ID with a signature, which can improve the security and stability of a system.
The technical scheme adopted by the invention is as follows:
in a first aspect, the present invention provides a method for generating a unique ID with a signature, including:
acquiring current system time and generating a time ID;
generating a sequence number by Redis;
generating a signature according to a preset signature rule;
combining the time ID, the serial number, and the signature to generate a unique ID.
As a further improvement of the foregoing scheme, the acquiring the current system time and generating the time ID specifically include:
acquiring the number of milliseconds of the current system time, and taking the difference between the number of milliseconds of the current system time and the number of milliseconds of the initial time of the system as a time ID.
As a further improvement of the above scheme, the generating of the sequence number by Redis specifically includes:
and acquiring a current system name as a keyword, combining the keyword and the time ID as a first key of Redis, generating a unique serial number, and storing the first key by the Redis.
As a further improvement of the foregoing scheme, the generating a signature according to a preset signature rule specifically includes:
extracting part of characters of the time ID as a first signature variable, extracting part of characters of the serial number as a second signature variable, and performing first logic operation on the first signature variable and the second signature variable to generate a third signature variable;
and performing second logic operation on the third signature variable and a preset signature key to generate a signature.
As a further improvement of the above scheme, the generating of the unique ID by combining the time ID, the serial number, and the signature specifically includes:
and sequentially splicing and combining the time ID, the serial number and the signature to generate a unique ID.
In a second aspect, the present invention provides a unique ID generation apparatus with signature, including:
the first generation module is used for acquiring the current system time and generating a time ID;
the second generation module is used for generating the serial number through Redis;
the third generation module is used for generating a signature according to a preset signature rule;
a combining module for combining the time ID, the serial number and the signature to generate a unique ID.
As a further improvement of the above aspect, the third generating module includes:
a first operation unit, configured to extract a partial character of the time ID as a first signature variable, extract a partial character of the serial number as a second signature variable, perform a first logical operation on the first signature variable and the second signature variable, and generate a third signature variable;
and the second operation unit is used for performing second logic operation on the third signature variable and a preset signature key to generate a signature.
In a third aspect, the present invention provides a unique ID generation device with signature, including:
at least one processor; and a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by at least one processor to enable the at least one processor to perform the signed unique ID generation method as described above.
In a fourth aspect, the present invention provides a computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method for generating a unique ID with a signature as described above.
The invention has the beneficial effects that:
the invention discloses a method, a device, equipment and a storage medium for generating a unique ID with a signature, which are used for generating a time ID by acquiring the current system time, generating a serial number by Redis, generating a signature according to a preset signature rule, combining the time ID, the serial number and the signature to generate the unique ID, generating the serial number by Redis, not needing to separately deploy a service for generating the ID, verifying the validity of the unique ID by the signature in the unique ID, shortening the response time of a system, improving the query efficiency, effectively shielding some illegal requests and improving the safety and stability of the system.
Drawings
The following further describes embodiments of the present invention with reference to the accompanying drawings:
FIG. 1 is a flowchart illustrating a method for generating a unique ID with a signature according to a first embodiment of the present invention;
fig. 2 is a block diagram of a unique ID generation apparatus with signature according to a third embodiment of the present invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
Example one
Fig. 1 is a flowchart illustrating a method for generating a unique ID with a signature according to a first embodiment of the present invention, and referring to fig. 1, a method for generating a unique ID with a signature includes steps S1 to S4.
S1, acquiring the current system time and generating a time ID;
s2, generating a serial number through Redis;
s3, generating a signature according to a preset signature rule;
s4, the time ID, the serial number, and the signature are combined to generate a unique ID.
In a specific embodiment, step S1 specifically includes:
acquiring the number of milliseconds of the current system time, and taking the difference between the number of milliseconds of the current system time and the number of milliseconds of the initial time of the system as the time ID.
In a specific embodiment, step S2 specifically includes:
and acquiring a current system name as a keyword, combining the keyword and the time ID as a first key of Redis, generating a unique serial number, and storing the first key by the Redis.
The current system name is used as a keyword for conveniently distinguishing different systems and devices. Redis supports a cluster mode, and already meets a high-availability scene, so that high availability of the generated serial number is ensured. In a specific embodiment, step S3 specifically includes:
s31, extracting partial characters of the time ID as a first signature variable, extracting partial characters of the serial number as a second signature variable, and performing first logic operation on the first signature variable and the second signature variable to generate a third signature variable;
and S32, performing a second logic operation on the third signature variable and a preset signature key to generate a signature.
The signature is used for verifying the validity of the unique ID, the background service can filter the unique ID through the signature of the unique ID, illegal ID requests are filtered, and the pressure of cache service and database service is reduced.
In a specific embodiment, step S4 specifically includes:
and sequentially splicing and combining the time ID, the serial number and the signature to generate a unique ID.
The method for generating the unique ID with signature according to the present invention is further described below with reference to the following embodiments.
The invention discloses a unique ID generation method with a signature, which comprises the steps of obtaining current system time, generating a time ID, generating a serial number through Redis, generating a signature according to a preset signature rule, combining the time ID, the serial number and the signature to generate the unique ID, generating the serial number through Redis, not needing to deploy a service for generating the ID independently, verifying the validity of the unique ID through the signature in the unique ID, shortening the response time of a system, improving the query efficiency, effectively shielding illegal requests and improving the safety and stability of the system.
Example two
A method of generating a unique ID with a signature, comprising the steps of:
s01, acquiring the current system time 2018:10: 100: 00:00, converting the current system time into a millisecond current timestamp 1538323200000, the system initial time is 2018:01: 0100: 00:00, converting the current system time into a millisecond initial timestamp 1514736000000, subtracting the current timestamp 1538323200000 from the initial timestamp 1514736000000 to obtain a time difference 23587200000, and converting the time difference 23587200000 into a binary character 00000010101111101111010000001110000000000, namely the time ID is 00000010101111101111010000001110000000000;
s02, acquiring the name of the current system as a keyword, combining the keyword with the time ID 00000010101111101111010000001110000000000 as a first key of Redis, and generating a unique serial number: 00000000001001, respectively;
s031, extracting the last four-bit string 0000 of the time ID as a first signature variable, extracting the last four-bit string 1001 of the serial number as a second signature variable, performing and operation on the first signature variable and the second signature variable to obtain a first signature subvariant, performing or operation on the first signature variable and the second signature variable to obtain a second signature subvariant, and splicing the first signature subvariant and the second signature subvariant to obtain a third signature variable 00001001;
s032, performing and operation on the third signature variable 00001001 and a preset signature key 10101100 to generate a signature 00001000;
s04, concatenating the time ID 00000010101111101111010000001110000000000, the serial number 00000000001001, and the signature 00001000 to generate the unique ID 0000000101011111011110100000011100000000000000000000100100001000, wherein the first bit of the unique ID is an identifier, a positive number is 0, and a negative number is 1.
EXAMPLE III
Fig. 2 is a block diagram of modules of a unique ID generation apparatus with signature according to a third embodiment of the present invention, and referring to fig. 2, a unique ID generation apparatus with signature includes:
the first generation module is used for acquiring the current system time and generating a time ID;
the second generation module is used for generating the serial number through Redis;
the third generation module is used for generating a signature according to a preset signature rule;
and the combination module is used for combining the time ID, the serial number and the signature to generate a unique ID.
In a particular embodiment, the third generating module includes:
the first operation unit is used for extracting partial characters of the time ID as a first signature variable, extracting partial characters of the serial number as a second signature variable, and performing first logic operation on the first signature variable and the second signature variable to generate a third signature variable;
and the second operation unit is used for performing second logic operation on the third signature variable and a preset signature key to generate a signature.
The unique ID generation apparatus with signature provided in the third embodiment of the present invention is configured to execute the unique ID generation method with signature in the first embodiment and the second embodiment, and the working principles and beneficial effects thereof are in one-to-one correspondence, and thus are not described again.
Example four
A unique ID generation device with signature, comprising:
at least one processor; and a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by at least one processor to enable the at least one processor to perform the signed unique ID generation method as in embodiments one and two above.
EXAMPLE five
A computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method for generating a unique ID with a signature as in the first and second embodiments.
The invention discloses a method, a device, equipment and a storage medium for generating a unique ID with a signature, which are used for generating a time ID by acquiring the current system time, generating a serial number by Redis, generating a signature according to a preset signature rule, combining the time ID, the serial number and the signature to generate the unique ID, generating the serial number by Redis, not needing to separately deploy a service for generating the ID, verifying the validity of the unique ID by the signature in the unique ID, shortening the response time of a system, improving the query efficiency, effectively shielding some illegal requests and improving the safety and stability of the system.
While the preferred embodiments of the present invention have been illustrated and described, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (9)

1. A method for generating a unique ID with a signature, comprising:
acquiring current system time and generating a time ID;
generating a sequence number by Redis;
generating a signature according to a preset signature rule;
combining the time ID, the serial number, and the signature to generate a unique ID.
2. The method as claimed in claim 1, wherein the obtaining the current system time and the generating the time ID specifically comprises:
acquiring the number of milliseconds of the current system time, and taking the difference between the number of milliseconds of the current system time and the number of milliseconds of the initial time of the system as a time ID.
3. The method as claimed in claim 1, wherein the generating of the serial number by Redis specifically comprises:
and acquiring a current system name as a keyword, combining the keyword and the time ID as a first key of Redis, generating a unique serial number, and storing the first key by the Redis.
4. The method as claimed in claim 1, wherein the generating a signature according to a preset signature rule specifically comprises:
extracting part of characters of the time ID as a first signature variable, extracting part of characters of the serial number as a second signature variable, and performing first logic operation on the first signature variable and the second signature variable to generate a third signature variable;
and performing second logic operation on the third signature variable and a preset signature key to generate a signature.
5. The method as claimed in any one of claims 1 to 4, wherein the generating the unique ID by combining the time ID, the serial number and the signature specifically comprises:
and sequentially splicing and combining the time ID, the serial number and the signature to generate a unique ID.
6. An apparatus for generating a unique ID with signature, comprising:
the first generation module is used for acquiring the current system time and generating a time ID;
the second generation module is used for generating the serial number through Redis;
the third generation module is used for generating a signature according to a preset signature rule;
a combining module for combining the time ID, the serial number and the signature to generate a unique ID.
7. The device of claim 6, wherein the third generating module comprises:
a first operation unit, configured to extract a partial character of the time ID as a first signature variable, extract a partial character of the serial number as a second signature variable, perform a first logical operation on the first signature variable and the second signature variable, and generate a third signature variable;
and the second operation unit is used for performing second logic operation on the third signature variable and a preset signature key to generate a signature.
8. A unique ID generation device with signature, characterized in that it comprises:
at least one processor; and a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by at least one processor to enable the at least one processor to perform the method of generating a unique ID with a signature as claimed in any one of claims 1 to 5.
9. A computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method of generating a unique ID with a signature as claimed in any one of claims 1 to 5.
CN201910007475.6A 2019-01-04 2019-01-04 Method, device and equipment for generating unique ID with signature and storage medium Pending CN111416879A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910007475.6A CN111416879A (en) 2019-01-04 2019-01-04 Method, device and equipment for generating unique ID with signature and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910007475.6A CN111416879A (en) 2019-01-04 2019-01-04 Method, device and equipment for generating unique ID with signature and storage medium

Publications (1)

Publication Number Publication Date
CN111416879A true CN111416879A (en) 2020-07-14

Family

ID=71493949

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910007475.6A Pending CN111416879A (en) 2019-01-04 2019-01-04 Method, device and equipment for generating unique ID with signature and storage medium

Country Status (1)

Country Link
CN (1) CN111416879A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090220072A1 (en) * 2008-02-28 2009-09-03 James Paul Schneider Secure serial number generation
US20110085474A1 (en) * 2009-10-09 2011-04-14 Ryoki Honjo Terminal device, signature generation server, simple id management system, simple id management method, and program
US20150026330A1 (en) * 2013-07-16 2015-01-22 Cellco Partnership D/B/A Verizon Wireless Generating unique identifiers for mobile devices
CN108959386A (en) * 2018-05-31 2018-12-07 深圳壹账通智能科技有限公司 Distributed globally unique ID generation method, device, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090220072A1 (en) * 2008-02-28 2009-09-03 James Paul Schneider Secure serial number generation
US20110085474A1 (en) * 2009-10-09 2011-04-14 Ryoki Honjo Terminal device, signature generation server, simple id management system, simple id management method, and program
US20150026330A1 (en) * 2013-07-16 2015-01-22 Cellco Partnership D/B/A Verizon Wireless Generating unique identifiers for mobile devices
CN108959386A (en) * 2018-05-31 2018-12-07 深圳壹账通智能科技有限公司 Distributed globally unique ID generation method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107396360B (en) Block verification method and device
US10686589B2 (en) Combining hashes of data blocks
WO2015156786A1 (en) Redactable document signatures
CN109033857B (en) Method, device and equipment for accessing data and readable storage medium
CN110930145A (en) Cold wallet generation method, transaction information processing method, device and storage medium
CN104954329A (en) Method and apparatus for processing biological characteristic information
CN111177225A (en) Account state existence proving method and device and state inquiring method and device
CN108234122B (en) Token checking method and device
CN104778252B (en) The storage method and device of index
CN109766724A (en) Data evidence storing method based on block chain
CN111327561B (en) Authentication method, system, authentication server, and computer-readable storage medium
CN111694502B (en) Block chain data storage method, device, equipment and storage medium
CN105592083A (en) Method and device for terminal to have access to server by using token
CN111416879A (en) Method, device and equipment for generating unique ID with signature and storage medium
US8776191B2 (en) Techniques for reducing storage space and detecting corruption in hash-based application
CN108365962B (en) Certificate revocation list query method and device
JP6233846B2 (en) Variable-length nonce generation
CN106250440B (en) Document management method and device
CN115333753A (en) Internet protocol address generation method and device, storage medium and electronic equipment
CN111147477B (en) Verification method and device based on block chain network
CN111064580B (en) Implicit certificate key expansion method and device
CN106357613A (en) Validation method of mobile terminal and validation system thereof
CN109657447B (en) Equipment fingerprint generation method and device
CN114884646B (en) System password storage method based on improved MD5 encryption processing
CN111342972B (en) Transaction realization method, device, equipment and medium of block chain

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20200714

RJ01 Rejection of invention patent application after publication