blob: 361c35b6ef850d224e993b65711c6e8e03db57fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from __future__ import print_function, division, absolute_import
import hashlib
import hmac
from wqflask import app
def hmac_creation(stringy):
"""Helper function to create the actual hmac"""
secret = app.config['SECRET_HMAC_CODE']
hmaced = hmac.new(secret, stringy, hashlib.sha1)
hm = hmaced.hexdigest()
# ZS: Leaving the below comment here to ask Pjotr about
# "Conventional wisdom is that you don't lose much in terms of security if you throw away up to half of the output."
# http://www.w3.org/QA/2009/07/hmac_truncation_in_xml_signatu.html
hm = hm[:20]
return hm
|