本文整理汇总了Python中message.Message.is_hex方法的典型用法代码示例。如果您正苦于以下问题:Python Message.is_hex方法的具体用法?Python Message.is_hex怎么用?Python Message.is_hex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message.Message
的用法示例。
在下文中一共展示了Message.is_hex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exchange_messages
# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import is_hex [as 别名]
def exchange_messages(self, msg_reply_list):
# Relay messages between terminal a and terminal b
end_a = self.other_term
end_b = self.eve
aes = get_aes(self.diffie_hellman_key)
reply_msg = Message({})
done = False
m = 0
while not done:
if reply_msg.is_empty():
print 'Try to receive from', end_a.name
reply_msg = end_a.receive_msg()
print 'From', end_a.name, '>>>\n', reply_msg
# Try to decode the message before relaying it to the other terminal
reply_msg_str = decipher(aes, reply_msg)
print 'Deciphered Message:', reply_msg_str
done = m == len(msg_reply_list)
if not done:
reply_msg = cipher(aes, msg_reply_list[m], reply_msg.iv)
m += 1
print 'Try to send message to', end_a.name
reply_msg = end_a.send_msg(reply_msg)
if not reply_msg.is_empty() and reply_msg.is_hex():
print 'From', end_a.name, '>>>\n', reply_msg
elif reply_msg.is_empty():
print 'Empty Response ... Terminating communications...'
done = True
elif not reply_msg.is_hex():
print 'From', end_b.name, '>>>\n', reply_msg.data
done = True