Mercurial > templog
diff py/uploader.py @ 536:3a27b1a09d2e
sha256 hash
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 19 May 2015 23:58:51 +0800 |
parents | 9b1d71310c83 |
children | 0a1b642e3086 ffe25107d520 |
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':