# Limit the length of AES encoded output to certain value

First let me be clear upfront that am not Crypto expert. I'm having a problem where I will have to use NFC card. Now given the limitation of NFC cards memory sizes, I will need to constraint my system to generate encoded data up to X amount of character.

Is there a way to limit character of AES encrypted data to not exceed certain limit? It would be easy with hashes but the data have to be reversible.

• Is there a limit on the amount of data you will have to encrypt? Also, what security guarantees do you require, just confidentiality or confidentiality+integrity? – mikeazo Dec 9 '15 at 16:37
• Yes there will be limited maxima for data. While I would like to have integrity checks but I can live without it. Confidentiality is the critical part of it – Stefano Mtangoo Dec 9 '15 at 17:04

AES operates on 128 bits of data. We can use modes of operation to turn AES (and any block cipher for that matter) into something that can handle longer (or shorter) data. If you want the ciphertext to be limited to X bits (above you said characters, I'm switching this to bits to make things easy), X must be at least as long as the plaintext data (compression may change that, but you must be very careful).