From a4b95f1c8cc3ad8f473f7e6abc9908c37101245a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 14 Jul 2021 19:14:02 +0800 Subject: [PATCH] bugfix --- appPublic/dataencoder.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/appPublic/dataencoder.py b/appPublic/dataencoder.py index 38d38bd..b5e62f2 100644 --- a/appPublic/dataencoder.py +++ b/appPublic/dataencoder.py @@ -88,11 +88,11 @@ class DataEncoder: pubkey = self.public_keys.get(peer_id) return pubkey - def pack(self, peer_id, data): + def pack(self, peer_id, data, uncrypt=False): pk = self.get_peer_pubkey(peer_id) print(peer_id, 'pk=', pk) t, d = self.identify_datatype(data) - if pk is None: + if uncrypt: return zlib.compress(b'\x00' * 18 + \ bytes(chr(t),'utf-8') + \ data) @@ -112,8 +112,9 @@ class DataEncoder: def unpack(self, peer_id, data): data = zlib.decompress(data) if data[:18] == b'\x00' * 18: - t = ord(data[18]) - d = data[19:] + data = data[18:] + t = ord(data[0]) + d = data[1:] if t == DATA_TYPE_BYTES: return d d = d.decode('utf-8')