Hash generator · Guide
MD5 Generator Random: Producing Random Hashes for Test Data
Sometimes you just need a plausible-looking 32-character hex string: a fixture row, a mock API response, a placeholder avatar id. Generating one is easy, but there is a distinction worth keeping straight.
Generating one
Hash something that changes every time — a random value, not a timestamp, since timestamps repeat under load and are guessable:
# shell
head -c 32 /dev/urandom | md5sum
# PHP
md5(random_bytes(16));
# Python
import hashlib, os
hashlib.md5(os.urandom(16)).hexdigest()If all you need is 32 random hex characters, skip MD5 entirely: bin2hex(random_bytes(16)) in PHP or os.urandom(16).hex() in Python gives the same shape with less indirection.
Randomness comes from the input, not the hash
A digest looks random because MD5 diffuses its input, but it contains no more entropy than what you fed it. Hashing a counter produces a random-looking sequence that is completely predictable to anyone who guesses the counter.
This matters when the value is used as a token, a session id or a password reset link. Those need a cryptographically secure random source directly — hashing a weak value does not upgrade it.
Better fits for test data
For unique identifiers in fixtures, UUID v4 says what it means and no reader wonders whether the value is meaningful. For deterministic tests, a fixed seed beats a random hash, because a failing test then reproduces.
Reserve random MD5 for the case where the field genuinely holds a digest and you want realistic-looking sample data — a mock checksum column, for example.
Frequently asked questions
Is a random MD5 hash unique?
With 128 bits from a good random source, collisions are not a practical concern. With a weak input source, uniqueness depends entirely on that source.
Can I use a random MD5 as a session token?
Only if it came from a cryptographically secure random source — and then the hashing step adds nothing. Use the random bytes directly.
Why not hash the current time?
Timestamps collide under concurrency and are trivially guessable, so the resulting digest is neither unique nor unpredictable.
Ready to try it?
Open the free browser-based Hash generator and apply what you just read — no sign-up, runs locally.
Open the Hash generator tool