aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2020-03-03 15:16:31 -0600
committerzsloan2020-03-03 15:16:31 -0600
commit8839637fbcb1b083e19367801ca7646962944d30 (patch)
tree988f3ec752afd3249b25faf5a798ddda51557354
parentf9849394e3a252b5a1ac59c78a06728d20ca69ed (diff)
downloadgenenetwork2-8839637fbcb1b083e19367801ca7646962944d30.tar.gz
was missing a couple files in last commit
-rw-r--r--wqflask/utility/hmac.py18
-rw-r--r--wqflask/wqflask/hmac_func.py19
2 files changed, 37 insertions, 0 deletions
diff --git a/wqflask/utility/hmac.py b/wqflask/utility/hmac.py
new file mode 100644
index 00000000..47001e54
--- /dev/null
+++ b/wqflask/utility/hmac.py
@@ -0,0 +1,18 @@
+from __future__ import print_function, division, absolute_import
+
+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 \ No newline at end of file
diff --git a/wqflask/wqflask/hmac_func.py b/wqflask/wqflask/hmac_func.py
new file mode 100644
index 00000000..361c35b6
--- /dev/null
+++ b/wqflask/wqflask/hmac_func.py
@@ -0,0 +1,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 \ No newline at end of file