I am looking for a PHP function that creates a short hash out of a string or a file, similar to those URL-shortening websites like tinyurl.com
The hash should not be longer than 8 characters.
I am looking for a PHP function that creates a short hash out of a string or a file, similar to those URL-shortening websites like tinyurl.com
The hash should not be longer than 8 characters.
I wrote a tiny lib to generate obfuscated hashes from integers.
http://web.archive.org/web/20130727034425/http://blog.kevburnsjr.com/php-unique-hash
7/14/2015: Adding the actual code below, since it has become difficult to find:
Actually the best solution to have "random" hash is to generate a list of random hash, put it on Mysql with an unique INDEX (you can write a simple UDF to insert 100 000 rows in 1 seconde).
I think a structure like this ID|HASH|STATUS|URL|VIEWS|......
Where status indicates if this Hash is free or not.