Search code examples
phphmac

How can I generate a HmacSHA256 signature of a string


Is there any way to create a HmacSHA256 signature of a string in php?


Solution

  • Use hash_hmac:

    $sig = hash_hmac('sha256', $string, $secret);
    

    Where $secret is your key.