Skip to content
This repository

random slug generation #3

Macphisto opened this Issue April 03, 2010 · 7 comments

4 participants

Macphisto Alan Hogan Eric Eggert Ian Storm Taylor

What about an option to generate a random slug from numbers and letters? I expected mixed-smart do to this but it seems to work differently.

Alan Hogan

I thought about this, and it would be a useful feature (providing “security through obscurity” by making URLs less guessable, for example).

However I don’t recognize it as a necessary feature, and haven’t decided on the best algorithm/implementation to do it.

Any suggestions?

This is an enhancement I may never get around to, so you’re very welcome to fork and implement this — I’ll be happy to answer any questions you may have, too, and merge it back in to my fork, etc.


I currently use something like this:

function random_url ()
$chars = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
$i = 0;
$url = '' ;

while ($i <= 4) {
    $num = rand() % 33;
    $tmp = substr($chars, $num, 1);
    $url = $url . $tmp;

return $url;

I'll have to take a closer look to your source to see if I can plug this in easily.

Eric Eggert
yatil commented April 19, 2011

I expected mixed-smart to render random URLs, with slugs that just increment the tool is quite useless, the urls shouldn’t be guessable.

Alan Hogan

You aren't the only one who expected it to work more like I plan to add this feature sometime soon-ish. Forks are welcome.

Ian Storm Taylor

Also assumed it worked this way.

I agree with less guessable URLs, but it also has the added bonus of not giving away all of the super-short URLs right away for things that might not be important. Those could be much more useful later when specifically chosen.

Alan Hogan
  1. Let’s see if I have the request right:

    • Current implementation lets you configure the alphabet used (alphanumeric, suppress homoglyphs, etc.)
    • Ideal implementation would also let you configure the target slug length and enable random/unguessable slugs (as opposed to linear/guessable).
  1. There are some Lessn More alternatives (yourls, I think?) that implement random slugs, if anyone needs them immediately (like yatil did).
Ian Storm Taylor

Sounds right to me.

A possibly helpful statistic to add next to them in a comment or in the readme would be permutations available for say 4-character slugs, 5-char, 6-char (aka just a range around the default) to give people an idea of what they are getting into. All for mixed-smart (as that seems like the most reasonable generation method).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.