Hi I want to check a string using the function mhash: mhash(MHASH_SHA256, $string) However my server does not have the mhash function installed. What is the alternative for mhash? Can I use this: hash("sha256", $string, "true")
They don't output the same values You will need to get some kind of a hex2bin function (which doesnt exist in php itself but you can find them). For example // hex2bin function by chaos79 taken from http://php.net/manual/en/function.bin2hex.php function hex2bin($h) { if (!is_string($h)) return null; $r = ''; for ($a = 0; $a < strlen($h); $a += 2) { $r .= chr(hexdec($h{$a}.$h{($a + 1)})); } return $r; } $string = 'example'; echo hex2bin(hash('sha256', $string)); PHP: This would output the exact same as echo mhash(MHASH_SHA256, $string); PHP: