[kwlug-disc] Hash functions.
kb at 2bits.com
Sun Jan 2 10:59:51 EST 2011
On Sun, Jan 2, 2011 at 5:46 PM, Joe Wennechuk <youcanreachmehere at hotmail.com
> I want to use a hash type function to generate a unique id for sms
> messages. I want the smallest possible number of bytes returned as the
> identifier, I can use all alnum, and even symbols maybe only ASCII up to
> 127, instead of 256. The input is going to be only 120 chrs+DateTime()+maybe
> some 10 digit identifier or something, so maybe 200-250 chrs max. for the
> input, and hopefully like 4-5 chrs for the output with collisions less than
> 1 in 500,000,000 or so (127^5 is like 33,000,000,000 so that seems
> ok???).... Is there a function to do this? All the ones I seem to see output
> in binary or hex only I think I could really reduce the size by using 127
> chars instaed of 16, and bites are critical to the app. I suppose I could do
> some parsing on the binary number and come up with something, but I rater
> just be done with it.
It is unclear to me if you say hex is acceptable or not.
If all you need is a unique hash from a string (however you generate it is
irrelevant), then a 32 character hash with hex values can be done using
$your_hash = md5($your_string);
Khalid M. Baheyeldin
Drupal optimization, development, customization and consulting.
Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra
Simplicity is the ultimate sophistication. -- Leonardo da Vinci
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the kwlug-disc_kwlug.org