Search code examples
phpsha1pack

WARNING: PACK(): IN xx ON LINE xxx


I am getting a warning from the pack function without any information. The string I am passing seems to be fine. Can anyone tell me what might be causing the issue?

$s = trim(hash_hmac('sha1', trim($stringToSign), $key));
$binary_hmac = pack(“H40”, $s);

$binary_hmac returns false.


Solution

  • Probably the quotes:

    $binary_hmac = pack(“H40”, $s);
                        ^---^---
    

    those are typographical quotes (e.g. microsoft smart-but-really-moronic quotes). Try switching to the normal " standard quotes.