The default encoding of Crypto hash.update() is binary as detailed in the answer to Node JS crypto, cannot create hmac on chars with accents. This causes a problem in your push-event payload, which contains the character U+00E1
LATIN SMALL LETTER A WITH ACUTE in Hernández
four times, and GitHub services is hashing the payload as utf-8
encoded. Note that your Gist shows these incorrectly-encoded in ISO-8859-1, so also make sure that you are handling the incoming request character-encoding properly (but this should happen by-default).
To fix this you need to either use a Buffer
:
hmac = crypto.createHmac('sha1', tok).update(new Buffer(blob, 'utf-8')).digest('hex');
… or pass the encoding directly to update
:
hmac = crypto.createHmac('sha1', tok).update(blob, 'utf-8').digest('hex');
The correct hash of 7f9e6014b7bddf5533494eff6a2c71c4ec7c042d
will then be calculated.