def encrypt(self, text, appid):
<EOL>text = self.get_random_str() + struct.pack("<STR_LIT:I>", socket.htonl(len(text))) + to_binary(text) + appid<EOL>pkcs7 = PKCS7Encoder()<EOL>text = pkcs7.encode(text)<EOL>cryptor = AES.new(self.key, self.mode, self.key[:<NUM_LIT:16>])<EOL>try:<EOL><INDENT>ciphertext = cryptor.encrypt(text)<EOL>return base64.b64encode(ciphertext)<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise EncryptAESError(e)<EOL><DEDENT>
对明文进行加密

        @param text: 需要加密的明文
        @return: 加密得到的字符串