Skip to content

Commit

Permalink
Use compare_digest in Python when comparing hex digests (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
starpogi authored and pirogoeth committed Dec 1, 2016
1 parent f267d54 commit e8b9270
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/user_manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,10 @@ Below is a Python code sample used to verify the signature:
import hashlib, hmac
def verify(api_key, token, timestamp, signature):
return signature == hmac.new(
key=api_key,
msg='{}{}'.format(timestamp, token),
digestmod=hashlib.sha256).hexdigest()
hmac_digest = hmac.new(key=api_key,
msg='{}{}'.format(timestamp, token),
digestmod=hashlib.sha256).hexdigest()
return hmac.compare_digest(unicode(signature), unicode(hmac_digest))
And here's a sample in Ruby:
Expand Down

0 comments on commit e8b9270

Please sign in to comment.