How do URL shortener's like bit.ly calculate a random key for each link? What algorithm would I need to know to create my own?
So far I found the code from http://briancray.com/2009/08/26/free-php-url-shortener-script/
function getShortenedURLFromID ($integer, $base = ALLOWED_CHARS)
{
$length = strlen($base);
while($integer > $length - 1)
{
$out = $base[fmod($integer, $length)] . $out;
$integer = floor( $integer / $length );
}
return $base[$integer] . $out;
}
and the more complex answer by Marcel J. mentioned above.