Last active
August 21, 2018 01:05
-
-
Save dariye/461744e4f1ad0c8852fa95d6f8284684 to your computer and use it in GitHub Desktop.
Validate github webhook event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto') | |
/** | |
* Sign request body using secret and HTTP request body | |
* @param {string} key Secret key | |
* @param {body} body HTTP request body | |
* @returns {string} Generate hash code | |
*/ | |
function signRequestBody (key, body) { | |
return `sha1=${crypto.createHmac('sha1', key).update(body, 'utf-8').digest('hex')}` | |
} | |
module.exports = { signRequestBody } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment