Generating random codes sounds easy — until real people have to read, type, or say them out loud. Suddenly O
looks like 0
, l
looks like 1
, and half your support tickets are about users mistyping their coupon or entry code.
To solve this, I built a small PHP library that generates human-friendly random strings using Crockford’s Base32 alphabet. It’s perfect for things like coupon codes, ticket entry codes, invite tokens, or any other short identifiers where clarity matters just as much as randomness.
👉 GitHub repo: CheckThisCloud/CrockfordRandom
Why Crockford’s Base32?
When generating codes for humans to type in or read back, you don’t want people misreading O
as 0
or l
as 1
.
Crockford’s alphabet solves this by removing ambiguous characters while keeping the string compact and case-insensitive.
Features
- Generate random strings of any length.
- Ideal for human-facing codes: tickets, coupons, invites, promo codes.
- Output uses only unambiguous characters.
- Built on PHP’s modern
Random\Randomizer
class. - Tiny footprint — easy to drop into any project.
Example usage
use CheckThisCloud\CrockfordRandom\CrockfordRandom;
$random = new CrockfordRandom();
echo $random->string(10);
// Example output: 9XF7T2K4HZ
Bonus: SillyNames 🎉
I’ve also built another micro-library: [CheckThisCloud/SillyNames]((https://github.com/CheckThisCloud/SillyNames)
.
It generates random two-word names in the style of Docker container names (e.g. brave_panda, sleepy_hedgehog).
Useful for test data, logs, or giving projects some personality.
Feedback is very welcome 🙏
Top comments (0)