Crypto: randomUUID() メソッド
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.
安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。
randomUUID()
は Crypto
インターフェイスのメソッドで、暗号強度の強い乱数生成器を用いて v4 UUID を生成するのに用いられます。
構文
js
randomUUID()
引数
なし。
返値
ランダムに生成された 36 文字の v4 UUID を格納した文字列。
例
メソッドにグローバルの crypto
プロパティを通してアクセスします。
js
/* self.crypto.randomUUID() が利用可能であることを仮定しています */
let uuid = self.crypto.randomUUID();
console.log(uuid); // 例えば "36b8f84d-df4e-4d49-b662-bcde71a8764f"
仕様書
Specification |
---|
Web Cryptography API # Crypto-method-randomUUID |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
randomUUID() |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
関連情報
Web Crypto API
Crypto
オブジェクトを取得するcrypto
。Crypto.getRandomValues
任意の量の安全なランダムバイト列の生成源。