summaryrefslogtreecommitdiff
path: root/searx/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/utils.py')
-rw-r--r--searx/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/searx/utils.py b/searx/utils.py
index 35b20ad83..8be7beb62 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -1,4 +1,6 @@
import csv
+import hashlib
+import hmac
import os
import re
@@ -321,3 +323,10 @@ def load_module(filename, module_dir):
module = load_source(modname, filepath)
module.name = modname
return module
+
+
+def new_hmac(secret_key, url):
+ if sys.version_info[0] == 2:
+ return hmac.new(bytes(secret_key), url, hashlib.sha256).hexdigest()
+ else:
+ return hmac.new(bytes(secret_key, 'utf-8'), url, hashlib.sha256).hexdigest()