<?php
function readableToken(int $len = 8): string {
// Crockford-style alphabet — no 0, O, 1, l, I, U
$alpha = 'ABCDEFGHJKMNPQRSTVWXYZ23456789';
$alphaLen = strlen($alpha);
$out = '';
for ($i = 0; $i < $len; $i++) {
// Rejection sampling for uniform distribution.
do { $b = ord(random_bytes(1)); } while ($b >= intdiv(256, $alphaLen) * $alphaLen);
$out .= $alpha[$b % $alphaLen];
}
return $out;
}
echo readableToken(6); // e.g. "K7TQ4N"
echo readableToken(12); // e.g. "X3RJ8H2BVQ7K"
Create a free account and build your private vault. Share publicly whenever you want.