function getHashNotWorking($argStrHashMethod, $argStrString)
{
$strHashMethod = 'MHASH_' . $argStrHashMethod;
$strHashedString = bin2hex(mhash($strHashMethod, $argStrString));
return $strHashedString;
}
echo getHashNotWorking('SHA512', 'some string');
This will return an error about the mhash function expecting a long type instead of a string.
=============================
for ($intI = 0; $intI <= mhash_count(); $intI++)
{
$arrHashTypes[mhash_get_hash_name($intI)] = $intI;
}
function getHashWorking($argStrType, $argStrString)
{
global $arrHashTypes;
$strHashedString = bin2hex(mhash($arrHashTypes[$argStrType], $argStrString));
return $strHashedString;
}
echo getHashWorking('SHA512', 'some string');
This will return the hash with the desired hash method