note 53161 deleted from function.md5 by mazzanet
| From: | mazzanet@php.net | Date: | Mon, 03 Oct 2005 09:42:12 +0000 |
| Subject: | note 53161 deleted from function.md5 by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96268@lists.php.net to get a copy of this message | ||
Note Submitter: mina86 dot spamsux at nospam dot projektcode dot org
----
Re: Robert Chapin
That's obvious. null is converted into an empty string.
Re: tommiboy
Ad 1. Even if N is < 128 (but > then another value) there must be a collision since there are
more then 2^128 strings of maximum length of 128 bits.
Ad 5. Still, 1) programmer should be aware of ever issue in his/her software and 2) it's better
not to have a bug then to have it even if it is very unlikely that anyone will use it.
Re: IndigoDarkwolf
The problem is that if one has a (let say) 15-letter long password containing only letters and
digits, the password's MD5 can be cracked using a home computer in no time (well.. it'll
take some time but still it's not hard).
Re: scott at rocketpack dot net
True, md5() returns only lower case letters but still a MD5 hash with upper case letter is still MD5
hash. It all depends on what you will be using this function for.
Re: marc at NOSPAM dot giombetti dot com
You're not correct. Check that out:
<?php
function valid_for_x_minutes($x, $opt = '') {
return md5($x!=0 ? (ceil(date('i')/$x)*$x) . $opt : time() . $opt);
}
// Wait till 59 seconds
sleep(59 - time()%60);
$hash1 = valid_for_x_minutes(1, 'foo');
sleep(2);
$hash2 = valid_for_x_minutes(1, 'foo');
echo($hash1 . "\n" . $hash2 . "\n");
?>
Though when $x>10 one minute doesn't make the difference but still better would be:
<?php
function valid_for_x_minutes($x, $opt = '') {
$x = (int)($x * 60);
return md5($x!=0 ? ceil(time()/(int)$x) . $opt : time() . $opt);
}
?>
Which of course wouldn't work for small $x