note 51085 added to function.md5
| From: | robbie | Date: | Sat, 19 Mar 2005 01:15:17 +0000 |
| Subject: | note 51085 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86674@lists.php.net to get a copy of this message | ||
If you are looking for other similar hashing functions, you can use the mhash lib: http://www.php.net/mhash.
It includes around 25 hashing algorithms including MD5, MD4 and SHA1.
Here's a little example of how to use mhash:
<?
$num_of_algs = mhash_count();
$string = "apples are nice";
for($i=0; $i<=$num_of_algs; $i++){
$name = @mhash_get_hash_name($i);
$hash = @mhash($i, $string);
# hash is in raw decimal form
$hex = bin2hex($hash);
# hex is in hexadecimal form
echo "<p>Hashed with: ".$name."<br /><b>Binary:</b>
".$hash."<br /><b>Hexadecimal</b>: ".$hex."</p>";
}
?>
@ used before function call incase a hash doesn't exist when it should. You can also use
if($hash) echo "<p>...
This will output both the raw binary output of each hash, and the hexadecimal output. You will
notice that the hashing algorithm "WHIRLPOOL" has a very long length, so it might be a
better choice over MD5.
----
Manual Page -- http://www.php.net/manual/en/function.md5.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51085
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51085&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51085&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51085&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51085&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51085&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51085&report=yes
Search -- http://master.php.net/manage/user-notes.php