keychain-uses-objects
quadrismegistus 4 years ago
parent e1d38700df
commit 2ba0789a8a

@ -109,16 +109,22 @@ class Operator(Keymaker):
# self.log('Message has being sealed in a final binary package:',b64encode(msg_b))
# return msg_b
def unseal_msg(self,msg_b_encr,from_whom=None,to_whom=None):
def unseal_msg(self,msg_b,from_whom=None,to_whom=None):
# default to assumption that I am the recipient
if not to_whom: to_whom=self
# decrypt by omega
# msg_b = self.omega_key.decrypt(msg_b_encr)
msg_b = msg_b_encr
# msg_b = msg_b_encr
# unpackage from transmission
msg_d = pickle.loads(msg_b)
# msg_d = pickle.loads(msg_b)
# get message obj
# print('unsealed msg:',msg_d)
msg_d = {
'from':from_whom.pubkey,
'to':to_whom,
'msg':msg_b
}
from komrade.backend.messages import Message
msg_obj = Message(msg_d,from_whom=from_whom,to_whom=to_whom)
# decrypt msg

@ -58,12 +58,13 @@ class TheOperator(Operator):
# ends the ring_ring() chain
def answer_phone(self,data_b):
# route incoming call from the switchboard
self.log('Hello, this is the Operator. You said: ',data_b)
self.log('Hello, this is the Operator. I heard you say:\n\n',b64encode(data_b))
# unseal
msg_obj = self.unseal_msg(
data_b,
from_whom=self.phone
from_whom=self.phone,
to_whom = self
)
self.log(f'Operator understood message: {msg_obj} {msg_obj.route}')

@ -35,11 +35,14 @@ def do_pause():
except KeyboardInterrupt:
exit('\n\nGoodbye.')
import textwrap as tw
def dict_format(d, tab=0):
def reppr(v):
if type(v)==bytes and not isBase64(v):
return b64encode(v).decode()
if type(v)==bytes:
if not isBase64(v):
v=b64encode(v)
v=v.decode()
v='\n'.join(tw.wrap(v,10))
return v
s = ['{\n\n']

Loading…
Cancel
Save