note 112585 deleted from function.md5 by peehaa
| From: | peehaa@php.net | Date: | Sun, 28 Apr 2019 10:52:58 +0000 |
| Subject: | note 112585 deleted from function.md5 by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210831@lists.php.net to get a copy of this message | ||
Note Submitter: programings at abv dot bg
----
This recursive function allow you to hash something in depth using md5().
<?php
function checksum($what, $depth = 1) {
$depth--;
if (!$depth)
return md5($what);
else
return md5(checksum($what, $depth));
}
?>
The function hashed the previous hash to md5() again and again for number of times and returns the
last received hash.
Example usage:
<?php
for ($i = 1; $i <= 10; $i++) {
echo "$i. ".checksum("test", $i)."<br />";
}
?>
It can be used for security purposes.