Crypto: randomUUID() method - Web APIs | MDN
Syntax
Parameters
None.
Return value
A string containing a randomly generated, 36 character long v4 UUID.
Examples
js
/* Assuming that self.crypto.randomUUID() is available */
let uuid = self.crypto.randomUUID();
console.log(uuid); // for example "36b8f84d-df4e-4d49-b662-bcde71a8764f"
Specifications
| Specification |
|---|
| Web Cryptography Level 2 # Crypto-method-randomUUID |
Browser compatibility
See also
- Web Crypto API
Crypto.getRandomValues, a source for arbitrary amounts of secure random bytes.