ГСЧ randomness lab

Utilities

UUID and random tokens

UUID v4, hex, base64, and PIN — one at a time or by the hundreds.

instant computed locally
Result Randomness: local CSPRNG
Click 'Generate' — the values will appear here.
Ready
Summary UUID v4
UUID format
36 characters
122 bit of entropy

122 bits: 128 random bits minus 6 bits for version and variant.

Generated values are visible on the screen and can end up in the browser history or a screenshot. For production secrets — use a server-side secret manager, not a tab with a generator.

What is UUID v4

UUID (universally unique identifier) is a 128-bit identifier, which is written with thirty-six characters: eight groups separated by a hyphen, for example 3f2a9c1e-7b4d-4f6a-9e21-8c5d0b7a4e13. The fourth version of the standard means that almost all bits in it are random.

Out of 128 bits, six are reserved: four bits go to the version number (in the third group it is always 4), two — to the RFC 4122 variant (the fourth group begins with 8, 9, a or b). That leaves 122 random bits—that's about 5.3 × 10³⁶ options.

The main property of a UUID is that it can be created anywhere without coordination with a server. Two independent applications almost never generate the same identifier, so it is convenient to generate a UUID on the client even before saving it to the database.

Where are UUIDs and tokens used

  • primary keys of tables, when auto-increment gets in the way or gives the database size;
  • request identifiers for logs and tracing between services;
  • idempotency keys for repeated API requests;
  • names of temporary files, folders, and sessions;
  • hex and base64 tokens for password reset and invitation links;
  • PIN codes for local testing — for example, in a demo stand.

How is a UUID different from a random string

A random string is just a set of characters without obligations. UUID is a standard: fixed length, canonical representation, a version and variant number inside, ready support in libraries of any language. If the value needs to be read by standard parsers and stored in a column uuid, take the UUID.

If you specifically need a token — for a link, API key, or file name — the format is more flexible. Hex is convenient because it consists only of digits and Latin letters a–f and does not require escaping. Base64 is denser: six bits per character instead of four, so a string of the same strength is a quarter shorter.

How much entropy is in the token

The entropy of the token is calculated as length × log₂(alphabet). For a PIN code, the alphabet is ten digits, so even 12 characters give only about 40 bits: such a code protects against random selection, but not against targeted brute force.

TypeCalculationEntropy
UUID v4122 random bits122 bits
HEX, 16 bytes16 × 8128 bits
HEX, 32 bytes32 × 8256 bits
Base64, 32 characters32 × 6192 bits
PIN, 6 digits6 × log₂(10)≈ 20 bits
Custom string, 24 of 32 characters24 × 5120 bits

How to handle tokens

  • for sessions and APIs — no less than 128 bits of entropy;
  • for disposable links — a short lifespan is more important than length;
  • store the hash of the token on the server, not the token itself;
  • do not write tokens in logs and analytics;
  • PIN — for local verification only, not for data access.
Frequently Asked Questions
Can a UUID v4 be repeated?
Theoretically yes, like any random value. The probability of a match for 122 bits is so small that it is neglected for practical purposes: to reach a one percent chance of a collision, around 10¹⁸ identifiers would need to be generated.
Why is there always a '4' in the third group?
This is the version number: four means 'random data.' The fourth group starts with 8, 9, a, or b — this is a sign of the RFC 4122 variant. Together they take up six bits and do not participate in randomness.
Will a UUID work instead of a password?
No, although there is enough entropy. UUID is intended for public identification: it is shown in links, logs, and interfaces, it is not considered a secret. For passwords, use a separate one. password generator.
Why is a hex token more convenient than base64?
Hex consists only of 0–9 and a–f: such strings can be safely inserted into URLs, file names, and SQL without escaping. Base64 is shorter, but contains the characters '+' and '/', which sometimes need to be replaced.
Is it possible to set your own alphabet?
Yes, in 'Own line' mode. Remove similar characters so that the value is easier to dictate, and watch the alphabet size: the smaller it is, the lower the entropy for the same length.
↑↓ navigation Enter to open Esc close