base.py 文件源码

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

项目:wechat-async-sdk 作者: ihjmh 项目源码 文件源码
def encrypt(self, text, appid):
        """???????

        @param text: ???????
        @return: ????????
        """
        # 16?????????????
        text = self.get_random_str() + struct.pack("I", socket.htonl(len(text))) + to_binary(text) + appid
        # ???????????????????
        pkcs7 = PKCS7Encoder()
        text = pkcs7.encode(text)
        # ??
        cryptor = AES.new(self.key, self.mode, self.key[:16])
        try:
            ciphertext = cryptor.encrypt(text)
            # ??BASE64????????????
            return base64.b64encode(ciphertext)
        except Exception as e:
            raise EncryptAESError(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号