changeset 241:86e638d564b0

sha256 hash
author Matt Johnston <matt@ucc.asn.au>
date Tue, 19 May 2015 23:58:51 +0800
parents 659953f2ee03
children 2caee09f41c4 d9b819dcac53
files py/uploader.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/py/uploader.py	Tue May 19 15:07:57 2015 +0000
+++ b/py/uploader.py	Tue May 19 23:58:51 2015 +0800
@@ -48,9 +48,9 @@
         if self.server.test_mode():
             D("Would upload %s to %s" % (js, config.UPDATE_URL))
             return
-        js_enc = binascii.b2a_base64(zlib.compress(js.encode()))
-        mac = hmac.new(config.HMAC_KEY.encode(), js_enc, hashlib.sha1).hexdigest()
-        send_data = {'data': js_enc, 'hmac': mac}
+        js_enc = binascii.b2a_base64(zlib.compress(js.encode())).strip()
+        mac = hmac.new(config.HMAC_KEY.encode(), js_enc, hashlib.sha256).hexdigest()
+        send_data = {'data': js_enc.decode(), 'hmac': mac}
         r = yield from asyncio.wait_for(aiohttp.request('post', config.UPDATE_URL, data=send_data), 60)
         result = yield from asyncio.wait_for(r.text(), 60)
         if result != 'OK':