does anyone know of an algorithm that generates hashes that look like tinyurl hashes from a string (url)
I think the requirements would be
case sensitive short numbers and alphabets only anything else?
does anyone know of an algorithm that generates hashes that look like tinyurl hashes from a string (url)
I think the requirements would be
case sensitive short numbers and alphabets only anything else?
I don't think tinyurl hashes the strings; they have a database ID (1, 2, 3) which is coverted to base 36 (0-9A-Z): http://en.wikipedia.org/wiki/Base_36
Hashes don't guarantee that collisions won't occur (assuming that you have more items to hash than there are possible values of the hash), rather, a good hash algorithm will make it so that collisions don't occur often.
This is important for URL generation because the total number of URLs that exist is greater than the values that can be stored in a fixed string hash.
Rather, I believe you see a counter that is incremented and uses a number system with a large base (like 62 for example, for digits 0-9, characters a-z and A-Z) to represent the value of the counter which is unique.