Hash Generator (MD5, SHA-256)→Specialized Version
#️⃣

UUID v4 Generator

Generate random version 4 UUIDs

UUID v4

128-bit random identifier, RFC 9562 version 4, lowercase and hyphenated.

  • 9629ad4b-df72-4176-bab8-c1946df7fdae

Values come from crypto.getRandomValues, the browser's CSPRNG. They are generated locally and never sent anywhere — but a secret that has been displayed on screen is only as private as the screen.

Version 4: Random, With Six Fixed Bits

A UUIDv4 is 128 bits, of which 122 are random. Six are fixed: four encode the version (4) and two encode the RFC 4122 variant. That is why every v4 UUID has a 4 at the start of the third group and one of 8, 9, a or b at the start of the fourth:

`` 9f1c8a2e-7b3d-4f6a-9c2e-1d8b4a6f3c07 ↑ ↑ version variant `

Checking those two positions is the cheapest way to tell a real v4 from a random hex string in the right shape.

Collisions

With 122 random bits, the probability of a collision stays negligible far beyond any realistic volume:

UUIDs generatedCollision probability
1 billion~1 in 10²¹
1 trillion~1 in 10¹⁵
10¹⁸~1 in 10⁵
You would need to generate a billion per second for 85 years to reach a 50% chance of one collision. In practice, collisions in production come from a broken random source, not from the birthday bound — which is exactly why this generator uses crypto.getRandomValues() rather than Math.random().

The Database Cost

Random UUIDs as primary keys are hard on B-tree indexes. Each insert lands at a random point in the index rather than at the end, which fragments pages, inflates the index and worsens cache locality. On a large, write-heavy table the difference against a sequential key is substantial.

Key typeInsert localitySortable by timeSize
Auto-increment integerSequentialYes4–8 bytes
UUIDv4RandomNo16 bytes
UUIDv7SequentialYes16 bytes
ULIDSequentialYes16 bytes
UUIDv7 puts a millisecond timestamp in the high bits, keeping the uniqueness and the distributed generation while restoring insert locality. If you are choosing today for a new table, it is usually the better default.

Where v4 Is Exactly Right

  • Identifiers generated on clients or across services with no coordination
  • Idempotency keys for API requests
  • Correlation and trace IDs
  • Anything where a sequential key would leak volume or ordering

Not a Secret

A v4 UUID is unguessable, which tempts people to use one as a capability — an unlisted URL, a password-reset token. It is 122 bits of randomness, so that is defensible in isolation, but UUIDs end up in logs, analytics, referrer headers and browser history in a way that real tokens are handled to avoid. Use a purpose-built token with an expiry for anything that grants access.

The Avalanche Effect

A one-character change produces a completely different digest — not a similar one. That property is what makes a hash useful as a fingerprint:

InputMD5CRC32
hello5d41402abc4b2a76b9719d911017c5923610a686
hello.d94c10e437d18531e122ed0b45badd2a0a39d4f1
Hello8b1a9953c4611296a827abf8c47804d7f7d18982
hello and Hello differ by one bit of one byte, and share no part of their output. RIPEMD-160 of hello is 108f07b8382412612c048d07d13f814118445acd, and of Hello is d44426aca8ae0a69cdbc4021c64fa5ad68ca32fe` — same story.

Digest Length and Collision Resistance

AlgorithmOutputBirthday boundStatus
CRC3232 bits~77,000 valuesChecksum only
MD5128 bits2⁶⁴ in theoryBroken — collisions in seconds
SHA-1160 bits2⁸⁰ in theoryBroken — SHAttered, 2017
RIPEMD-160160 bits2⁸⁰No practical attack
SHA-256256 bits2¹²⁸Current standard
SHA-512512 bits2²⁵⁶Standard, faster on 64-bit
The birthday bound is where a 50% chance of *some* collision appears among random inputs. MD5 and SHA-1 fall far short of theirs because both have practical collision attacks — you can construct two different files with the same digest, which is precisely what a signature must prevent.

Never Hash a Password With These

A general-purpose hash is designed to be fast, which is exactly wrong for passwords: speed helps the attacker. Use a deliberately slow KDF — bcrypt, scrypt or Argon2id — with a per-password salt. A GPU tries billions of SHA-256 guesses a second and a few thousand bcrypt guesses a second, and that gap is the entire defence.

Frequently Asked Questions

Are these UUIDs cryptographically random?

Yes. They are generated with `crypto.getRandomValues()`, the browser’s CSPRNG, rather than `Math.random()`. The 122 random bits are drawn from the same source that backs key generation, and nothing is transmitted or stored.

Can two UUID v4 values collide?

Mathematically yes, practically no. With 122 random bits you would need to generate a billion per second for roughly 85 years to reach a 50% chance of a single collision. Real-world collisions come from a broken random source, not from the birthday bound.

Should I use UUID v4 as a database primary key?

Often UUIDv7 is better. Random UUIDs land at random points in a B-tree index, which fragments pages and hurts insert performance on large tables. UUIDv7 keeps the same uniqueness and distributed generation but sorts by time, restoring insert locality.

Related Tools

Explore other tools you might find useful:

More Hash Generator (MD5, SHA-256) tools

You might also need