WXBizMsgCrypt.py 文件源码

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

项目:wechat_mall 作者: a741424975game 项目源码 文件源码
def encrypt(self, text, appid):
        """???????
        @param text: ???????
        @return: ????????
        """
        # 16?????????????
        pack_str = struct.pack(b"I", socket.htonl(len(text)))
        text = smart_bytes(self.get_random_str()) + pack_str + smart_bytes(text) + smart_bytes(appid)
        # ???????????????????
        pkcs7 = PKCS7Encoder()
        text = pkcs7.encode(text)
        # ??
        cryptor = AES.new(self.key, self.mode, self.key[:16])
        try:
            ciphertext = cryptor.encrypt(text)
            # ??BASE64????????????
            return WXBizMsgCrypt_OK, base64.b64encode(ciphertext)
        except Exception:
            return WXBizMsgCrypt_EncryptAES_Error, None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号