I want to convert a string into a unique integer value that lies within a range. What I will be doing is feeding a given URL, or MD5 hash of that URL as input to a formula that returns a value not less than the bottom of my range, and not greater than my range.
For example, lets say I have http://www.yourdomain.com/cats/
as a string, and a range from one (1) to sixty (60).
All I need is to feed that URL into the formula, and it evaluates it somehow into a number that falls between 1 and 60. But if I have a large set of very similar, but unique URLS, I need to get a fairly even distribution between that range. That is to say, if I had 60 unique strings, I could probably get numbers anywhere in that range.
As another example, two similar strings such as:
might return what seems like random values between 1 and 60, as oppose to two integers that are very close to each other (because the strings are the same)
So I was thinking, maybe perform an md5 hash on the string, and then add up the ASCII values of each character in the MD5 hash. Then somehow use this get my number betwwen 1 and 60.
This "number" will act sort of as a serial number for the string, always the same unique evaluation between those ranges. The upper value in my range with be the last record in a database table. I'll use the "serial number" to always retreive the same record from the table.
At some point in the future, I'll want each url to have a new unique serial number, so all I do is extend my range (for example, as records are added to the database table).