On Oct 30, 2007, at 12:34 PM, Kimball Larsen wrote:
> So, I have a need to take any old string of any length, in any
> encoding, with any content (ok, it will typically be 32 chars or
> less, but that's not important - you'll see why in a moment) and
> convert it into a short(ish) number in integer form.
Dim v As Variant = myString
return v.Hash
(or v.Hash mod whatever your maximum allowable value is).
> m = NewMemoryBlock(17)
> m.CString(0) = md5(s)
> return m.UInt16Value(0)
Hmm, I wouldn't necessarily trust this, since (as you pointed out)
you're taking only the first two bytes of a 16-byte hash. It's
probably reasonably unique, but I'd be a bit nervous about it.
Best,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|