• Now all data be ready for publish, We had made our blog alive now. Haha.



  • These days CCP GFW blocked all the IPs from US and when I switch my IP in google Cloud, the disk data cannot be restore again. I have to restart my blog totally, Now the website is still building…



Create GUID / UUID in JavaScript?- Stack Overflow

Python PingBook 2 months ago (10-26) 22 0

Question

I’m trying to create globally-unique identifiers in JavaScript. I’m not sure what routines are available on all browsers, how “random” and seeded the built-in random number generator is, etc..

The GUID / UUID should be at least 32 characters and should stay in the ASCII range to avoid trouble when passing them around.

Answer

UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier), according to RFC 4122, are identifiers with a certain uniqueness guarantee.

The best way to generate them, is to follow implementation instructions in the said RFC, use one of the many community vetted open source implementations.

A popular Open Source tool for working with UUIDs in JavaScript is node-uuid

Note that just randomly generating the identifiers byte by byte, or character by character, will not give you the same guarantees as a conforming implementation. Also, very important, systems working with compliant UUIDs may choose not to accept randomly generated ones, and many open source validators will actually check for a valid structure.

An UUID must have this format:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

Where the M and N positions may only have certain values. At this time, the only valid values for M are 1, 2, 3, 4 and 5, so randomly generating that position would make most results unacceptable.




Copyright from PingBook Blog, If not specified, they are original. This site uses BY-NC-SAProtocol authenticated.
For reprinting, please indicate the link of the original text:Create GUID / UUID in JavaScript?- Stack Overflow
LIKE (0)
[1725641479@qq.com]
SHARE (0)
PingBook
Author:
We create, We sharing! Tag every value data your sharing
Submit comments
Cancel comments
emoji picture bold strikethrough center italic check in

Hi,you need to provide your name and email adress!

  • Name (Required)
  • Email (Required)
  • Website