Commit 8f4aa01e authored by Tobias Mueller's avatar Tobias Mueller

Merged sha256 hmac

parents 42b60ac6 79820968
......@@ -18,6 +18,7 @@
from __future__ import unicode_literals
import dbus
import hashlib
import hmac
import logging
import requests
......@@ -40,9 +41,11 @@ log = logging.getLogger(__name__)
def mac_generate(key, data):
mac =, data).hexdigest().upper()
mac =, data, hashlib.sha256).hexdigest().upper()"MAC of %r is %r", data[:20], mac[:20])
return mac
# Arbitrary truncation to avoid a QR code size increase
return mac[:20]
def mac_verify(key, data, mac):
computed_mac = mac_generate(key, data)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment