Voting

: four minus two?
(Example: nine)

The Note You're Voting On

labarks
21 years ago
Append this to the your sha1lib file to make it more portable. If your version of php does support sha1() then it will try to use Mhash or else it will use the sha1lib. Use $sha1 if you want to display which is being used.

if ( function_exists('sha1') )
$sha1 = "sha1";

if ( !function_exists('sha1') && function_exists('mhash'))
{
function sha1($hash_source)
{
$hash = mhash(MHASH_SHA1, $hash_source);
$hex_hash = bin2hex($hash);
return $hex_hash;
}
$sha1 = "Mhash";
}
if ( !function_exists('sha1') && !function_exists('mhash'))
{
function sha1( $string, $raw_output = false )
{
$library = new Sha1Lib();

return $raw_output ? $library->str_sha1($string) : $library->hex_sha1($string);
}
$sha1 = "sha1lib";
}

<< Back to user notes page

To Top