<div dir="ltr">On Sun, Jan 2, 2011 at 5:46 PM, Joe Wennechuk <span dir="ltr"><<a href="mailto:youcanreachmehere@hotmail.com">youcanreachmehere@hotmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">




<div>
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. <br>
</div></blockquote></div><br>It is unclear to me if you say hex is acceptable or not.<br><br>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 md5().<br>
<br>$your_hash = md5($your_string);<br><br><a href="http://php.net/manual/en/function.md5.php">http://php.net/manual/en/function.md5.php</a><br>-- <br>Khalid M. Baheyeldin<br><a href="http://2bits.com">2bits.com</a>, Inc.<br>
<a href="http://2bits.com">http://2bits.com</a><br>Drupal optimization, development, customization and consulting.<br>Simplicity is prerequisite for reliability. --  Edsger W.Dijkstra<br>Simplicity is the ultimate sophistication. --   Leonardo da Vinci<br>

</div>