해시/암호화
UUID Generator
버전 1, 3, 4, 5, 6, 7 UUID 생성 — 무작위, 시간 기반, 이름 기반(name-based).
A UUID (Universally Unique Identifier) is a 128-bit identifier that's unique in practice without a central registry: two independent servers can generate one at the same moment and almost never collide. The versions differ in how they're generated.
Which version to pick
- v4 — fully random, the most common choice for database record IDs, session keys, and similar cases.
- v1 and v6 — based on creation time; v6 carries the same content as v1 but with the fields reordered so it sorts naturally — handy as a primary key.
- v3 and v5 — deterministic, derived from a namespace and a name (v3 uses MD5, v5 uses SHA-1) — the same input always produces the same UUID.
- v7 — the newest standard: a millisecond Unix timestamp plus a random part, sortable by time like v1/v6, but without a MAC address.
Common uses
- Primary keys in databases where auto-increment doesn't fit (distributed systems, offline-first apps).
- Session IDs, request IDs for tracing, temporary file names.
- Deterministic IDs (v5) for objects that need the same identifier across different systems given the same name.
Things to keep in mind
UUID v1 and v6 embed the generating device's MAC address — avoid them if that's an unwanted disclosure.
The format is 32 hexadecimal characters grouped with hyphens as 8-4-4-4-12 (e.g. 550e8400-e29b-41d4-a716-446655440000).
자주 묻는 질문
UUID v4와 다른 버전의 차이는 무엇인가요?
v4는 대부분의 비트를 무작위로 채워 생성하는 반면, v1과 v6은 생성 시각과 노드 정보를 기반으로 하고 v3/v5는 네임스페이스와 이름을 해시해 생성합니다. 용도에 따라 시간 순서가 필요하면 v1/v6/v7을, 단순 무작위 식별자면 v4를 선택하면 됩니다.
UUID v4가 중복될 가능성이 있나요?
v4는 122비트의 무작위성을 가지므로 충돌 확률은 사실상 무시할 수 있는 수준입니다. 수십억 개를 생성해도 우연히 같은 값이 나올 확률은 천문학적으로 낮습니다.
UUID는 주로 어디에 쓰이나요?
데이터베이스 기본 키, 세션 토큰, 파일이나 객체의 고유 식별자 등 전역적으로 유일한 값이 필요한 곳에 널리 사용됩니다.
UUID v7이란 무엇이고 데이터베이스에서 v4보다 나은 점은 무엇인가요?
UUID v7은 앞쪽 비트에 타임스탬프를 담아 값이 생성 시간 순서로 자연스럽게 정렬됩니다 — 반면 완전히 무작위인 v4는 새 레코드가 무작위 위치에 삽입되어 데이터베이스 인덱스 성능에 나쁜 영향을 줍니다.
UUID를 비밀 토큰으로 사용해도 되나요?
UUID v4라면 가능합니다. 암호학적으로 안전한 난수 생성기로 생성되기 때문입니다. 하지만 UUID v1은 생성 시각과 장치의 MAC 주소 일부를 노출하므로, 예측 불가능성이 필요한 곳에는 적합하지 않습니다.