<s> """<STR_LIT>""" <EOL> from . cryptomath import * <EOL> from . aes import * <EOL> from . rijndael import rijndael <EOL> def new ( key , mode , IV ) : <EOL> return Python_AES ( key , mode , IV ) <EOL> class Python_AES ( AES ) : <EOL> def __init__ ( self , key , mode , IV ) : <EOL> AES . __init__ ( self , key , mode , IV , "<STR_LIT>" ) <EOL> self . rijndael = rijndael ( key , <NUM_LIT:16> ) <EOL> self . IV = IV <EOL> def encrypt ( self , plaintext ) : <EOL> AES . encrypt ( self , plaintext ) <EOL> plaintextBytes = stringToBytes ( plaintext ) <EOL> chainBytes = stringToBytes ( self . IV ) <EOL> for x in range ( len ( plaintextBytes ) // <NUM_LIT:16> ) : <EOL> blockBytes = plaintextBytes [ x * <NUM_LIT:16> : ( x * <NUM_LIT:16> ) + <NUM_LIT:16> ] <EOL> for y in range ( <NUM_LIT:16> ) : <EOL> blockBytes [ y ] ^= chainBytes [ y ] <EOL> blockString = bytesToString ( blockBytes ) <EOL> encryptedBytes = stringToBytes ( self . rijndael . encrypt ( blockString ) ) <EOL> for y in range ( <NUM_LIT:16> ) : <EOL> plaintextBytes [ ( x * <NUM_LIT:16> ) + y ] = encryptedBytes [ y ] <EOL> chainBytes = encryptedBytes <EOL> self . IV = bytesToString ( chainBytes ) <EOL> return bytesToString ( plaintextBytes ) <EOL> def decrypt ( self , ciphertext ) : <EOL> AES . decrypt ( self , ciphertext ) <EOL> ciphertextBytes = stringToBytes ( ciphertext ) <EOL> chainBytes = stringToBytes ( self . IV ) <EOL> for x in range ( len ( ciphertextBytes ) // <NUM_LIT:16> ) : <EOL> blockBytes = ciphertextBytes [ x * <NUM_LIT:16> : ( x * <NUM_LIT:16> ) + <NUM_LIT:16> ] <EOL> blockString = bytesToString ( blockBytes ) <EOL> decryptedBytes = stringToBytes ( self . rijndael . decrypt ( blockString ) ) <EOL> for y in range ( <NUM_LIT:16> ) : <EOL> decryptedBytes [ y ] ^= chainBytes [ y ] <EOL> ciphertextBytes [ ( x * <NUM_LIT:16> ) + y ] = decryptedBytes [ y ] <EOL> chainBytes = blockBytes <EOL> self . IV = bytesToString ( chainBytes ) <EOL> return bytesToString ( ciphertextBytes ) </s>
