note 72670 deleted from function.hash by thiago
| From: | thiago@php.net | Date: | Wed, 17 Jun 2009 12:12:16 +0000 |
| Subject: | note 72670 deleted from function.hash by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156970@lists.php.net to get a copy of this message | ||
Note Submitter: Peter Kelly
----
If the hash functions are not available to you at the moment, and you want to future proof your
code, then the code below will emulate two of the important hashing functions, they will also be
automatically replaced with the faster versions if available.
<?php
if(!function_exists('hash_algos'))
{
function hash_algos()
{
$algo[0] = "md5";
$algo[1] = "sha1";
$algo[2] = "crc32";
return($algo);
}
}
if(!function_exists('hash'))
{
function hash($algo, $data, $raw_output = 0)
{
if($algo == 'md5') return(md5($data));
if($algo == 'sha1') return(sha1($data));
if($algo == 'crc32') return(crc32($data));
}
}
?>