sinceramente sha2 non so se esiste!?
cmq ho trovato quest'esempio, forse ti sarà utile:

Codice PHP:


$phrase 
"Hello World";

$sha1a =  base64_encode(sha1($phrase));
$sha1b =  base64_encode(bin2hex(mhash(MHASH_SHA1,$phrase)));
$sha256bbase64_encode(bin2hex(mhash(MHASH_SHA256,$phrase)));

echo (
"SHA1..:" $sha1a "\n");
echo (
"SHA1..:" $sha1b "\n");
echo (
"SHA256:" $sha256b "\n");

# php sha.php
SHA1..:MGE0ZDU1YThkNzc4ZTUwMjJmYWI3MDE5NzdjNWQ4NDBiYmM0ODZkMA==
SHA1..:MGE0ZDU1YThkNzc4ZTUwMjJmYWI3MDE5NzdjNWQ4NDBiYmM0ODZkMA==
SHA256:YTU5MWE2ZDQwYmY0MjA0MDRhMDExNzMzY2ZiN2IxOTBkNjJjNjV...........