@staticmethod<EOL><INDENT>def _aes_encrypt(data, algorithm, key):<DEDENT>
if algorithm['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>mode = AES.MODE_CBC<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>% algorithm['<STR_LIT>'])<EOL><DEDENT>iv_size = algorithm['<STR_LIT>']<EOL>block_size = iv_size<EOL>include_iv = True<EOL>if '<STR_LIT>'in algorithm and algorithm['<STR_LIT>']:<EOL><INDENT>if len(algorithm['<STR_LIT>']) != algorithm['<STR_LIT>']:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>iv_value = algorithm['<STR_LIT>']<EOL>include_iv = False<EOL><DEDENT>else:<EOL><INDENT>iv_value = get_random_bytes(iv_size)<EOL><DEDENT>numpad = block_size - (len(data) % block_size)<EOL>data = data + numpad * chr(numpad)<EOL>enc = AES.new(key, mode, iv_value).encrypt(data)<EOL>if include_iv:<EOL><INDENT>enc = iv_value + enc<EOL><DEDENT>return enc<EOL>
AES encrypt