|  | Posted by Jerry Stuckle on 12/13/06 02:37 
Norman Peelman wrote:> "Toby Inkster" <usenet200611@tobyinkster.co.uk> wrote in message
 > news:l22354-d0o.ln1@ophelia.g5n.co.uk...
 >
 >>Norman Peelman wrote:
 >>
 >>
 >>>Well, I knew i'd get some flak for that. :)  I was assuming they would
 >
 > be
 >
 >>>unique enough for the situation.
 >>
 >>There are varying degrees of uniqueness?
 >>
 >>--
 >>Toby A Inkster BSc (Hons) ARCS
 >>Contact Me  ~ http://tobyinkster.co.uk/contact
 >>
 >
 >
 >     The poster is converting strings not files to md5. md5 is not a method
 > of encryption per se but a more complicated method of CRC to 'help' validate
 > data... It is convienent to use md5 to 'one-way encrypt' small strings used
 > as passwords. I would assume that the poster is also storing the matching
 > plaintext along with the md5 so if a match was found he could then see if
 > the plaintext matched as well but, according to the definitions i've read on
 > the net; the odds are extremely high, paraphrasing:
 >
 > Taken from
 > http://www.google.com/search?hl=en&lr=&defl=en&q=define:MD5&sa=X&oi=glossary_definition&ct=title
 >
 > The odds of any two strings having the same md5 are on the order of 2^64
 > operations.
 > The odds of finding a string having a given md5 is on the order of 2^128
 > operations.
 >
 > ...so yes, i'd say that there are variable degrees of uniqueness. So maybe
 > an easier way than my first post would be:
 >
 > Using textmd5 as PRIMARY KEY
 >
 > $db_link = mysql_connect(...,...,...); //etc.
 > $query = "INSERT INTO logs_full VALUES ($textmd5, $textplain)";
 > $resone = mysql_query($query, $dbc);
 > if (!mysql_errno($db_link))
 > {
 >     // match found (duplicate entry for key error 1062 returned from MySQL)
 >     // could then double check textplain here although odds of being here
 > are very high
 >     // do other stuff here
 > }
 > else
 > {
 >     // no match found
 >     // new entry has just been inserted
 > }
 >
 >    Of course this assumes he is also storing new md5's to check against.  I
 > gueuss we don't fully know what the poster completely intends on doing
 > unless he pops back in with a little more info.
 >
 > Norm
 >
 >
 
 And when you're comparing unknown strings, the odds go down rapidly.
 
 The odds of anyone having the same birthday as you is 1 in 365.25.
 However, in a group of 24 people, the odds of any two of them having the
 same birthday are 1 in 2.
 
 I don't have the time (or inkling) to determine how many md5 hashes you
 would have to generate to get a reasonable chance of hitting a
 duplicate.  But it is much less than 2^64.
 
 --
 ==================
 Remove the "x" from my email address
 Jerry Stuckle
 JDS Computer Training Corp.
 jstucklex@attglobal.net
 ==================
  Navigation: [Reply to this message] |