# Can we determine the size of n-bytes before encryption by AES-128?

I am writing a program in python to encrypt files. This program takes subsequent 1024*1024 (1 mebibyte) chunks of data from a file and encrypts it using AES-128. This is performed in a loop until all the data in the file is encrypted. The issue is that the size of each 1 mebibyte of data is increased when it gets encrypted.

What I need is a way to determine the new chunk size for each 1 mebibyte after its gets encrypted .

Very often CBC mode encryption is the default mode of operation on low level cryptographic API's. In that case - because your chunk of data is a multiple of the AES block size (16 bytes) - the ciphertext expansion is one full block of 16 bytes. If the IV is prefixed before the ciphertext then it will grow with another 16 bytes. The calculation for CBC padding size is N - (L % N) where N is the block size and L is the plaintext chunk size, both in bytes.