Crypto: randomUUID() Methode

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Sicherer Kontext: Diese Funktion ist nur in sicheren Kontexten (HTTPS) in einigen oder allen unterstützenden Browsern verfügbar.

Hinweis: Diese Funktion ist in Web Workers verfügbar.

Die randomUUID() Methode des Crypto Interfaces wird verwendet, um eine v4 UUID mit einem kryptographisch sicheren Zufallszahlengenerator zu erzeugen.

Syntax

js
randomUUID()

Parameter

Keine.

Rückgabewert

Ein String, der eine zufällig generierte, 36 Zeichen lange v4 UUID enthält.

Beispiele

js
/* Assuming that self.crypto.randomUUID() is available */

let uuid = self.crypto.randomUUID();
console.log(uuid); // for example "36b8f84d-df4e-4d49-b662-bcde71a8764f"

Spezifikationen

Specification
Web Cryptography API
# Crypto-method-randomUUID

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
randomUUID()

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

Siehe auch