|
Posted by Norman Peelman on 12/12/06 21:19
"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
Navigation:
[Reply to this message]
|