This page was translated from English by the community. Learn more and join the MDN Web Docs community.
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 2022년 3월.
참고 : 이 기능은 Web Worker에서 사용할 수 있습니다.
Crypto 인터페이스에 속한 randomUUID() 메서드는 암호학적으로 강력한 난수 생성기를 이용해서 v4 UUID를 생성합니다.
구문
js
randomUUID()
매개 변수
없음.
반환 값
무작위로 생성된 36자의 v4 UUID를 포함하는 문자열을 반환합니다.
예제
js
/* self.crypto.randomUUID()를 사용할 수 있다고 가정합니다. */
let uuid = self.crypto.randomUUID();
console.log(uuid); // 예시: "36b8f84d-df4e-4d49-b662-bcde71a8764f"
명세서
| Specification |
|---|
| Web Cryptography Level 2> # Crypto-method-randomUUID> |
브라우저 호환성
Enable JavaScript to view this browser compatibility table.
같이 보기
- Web Crypto API
Crypto.getRandomValues는 임의의 크기에 대한 안전한 무작위 바이트를 생성하는 메서드입니다.