Skip to content

Instantly share code, notes, and snippets.

View timo-reymann's full-sized avatar
🦄
dreaming of being a unicorn

Timo Reymann timo-reymann

🦄
dreaming of being a unicorn
View GitHub Profile
@rms1000watt
rms1000watt / main.py
Created December 14, 2018 18:19
github webhook secret hash hmac sha1 digest compare python lambda function through AWS API Gateway
import hmac
import hashlib
def equal_hash(event):
secret_value = "secret-value-put-in-github-webhook-ui"
sigExpected = str(event["headers"]["X-Hub-Signature"].replace("sha1=", ""))
sigCalculated = str(hmac.new(secret_value, event["body"], hashlib.sha1).hexdigest())
return hmac.compare_digest(sigCalculated, sigExpected)