iddp.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:IoT-Client 作者: suquark 项目源码 文件源码
def generate_msg(role, msg_dict=None):
    """
    See `IoT Protocol Specification`
    :param msg_dict: The data dict.
    :param role:
    :return: Encrypted bytes
    """
    logging.debug("Generating a message ...")
    msg = {'proto': 'iddp',
           'role': role,
           'timestamp': datetime.datetime.utcnow().timestamp(),
           'id': identity,
           'data': msg_dict}

    msg = simplejson.dumps(msg, separators=(',', ':')).encode()
    return crypto.encrypt(gzip.compress(msg))[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号