WXBizMsgCrypt.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号