|
Re: Primary Key Hash help: msg#01104lang.ruby.general
On Tue, Aug 13, 2002 at 12:21:44AM +0900, Sean Middleditch wrote: > Yes and yes. MD5 is a standardized specification (thus it will always > have the same output in all implementations, assuming no bugs are > present), and it's size in bits is fixed (forget off the top of my head > what size exactly it is). 128 bits. Another fail-proof way which guarantees no clashes would be join()'ing the fields and expanding the resulting string to a fixed size. Anyway, collisions would be _very_ rare with MD5... You can also make them even more uncommon this way: 1) get the MD5sum of "#{row}" 2) get the MD5sum of "#{row}_an arbitrary string_" 3) concat the results from 1) and 2) and you've got a 256 bits "extended" MD5 You can repeat 2) as many times as you like and rest assured that an asteroid crashing on your computer is more probable than this "extended" MD5 giving the same value for 2 different rows :-) You can also compare it with the probability of a hardware failure (or that of a bug in your code, if you're really *good* at it :-) -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Beeping is cute, if you are in the office ;) -- Alan Cox
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Ruby Language Q's, ts |
|---|---|
| Next by Date: | Re: Ruby Language Q's, dblack |
| Previous by Thread: | Re: Primary Key Hash help, Sean Middleditch |
| Next by Thread: | Re: Primary Key Hash help, Tim Hunter |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |