Created
July 19, 2015 17:08
-
-
Save dmendiza/3846d876db0d491416c0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# import hmac library | |
import hmac | |
# configure a key | |
HMAC_KEY = 'O\x8cNd\x16E\xb1U\x1b\x0b\xe8\t\xd8\xab\xbcI' | |
# change signing function to use hmac | |
ctx = hmac.new(KEY, digestmod=hashlib.sha256) | |
ctx.update(request.args["data"]) | |
digest = ctx.hexdigest() | |
# change verification function to use hmac | |
ctx = hmac.new(KEY, digestmod=hashlib.sha256) | |
ctx.update(request.args["data"]) | |
computed_digest = ctx.hexdigest().decode('utf8') | |
if hmac.compare_digest(request.args["digest"], computed_digest): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment