Search code examples
stringencryptioncryptographyaes

AES encryption constant input and output size


I have a key for AES encryption and I'm trying to encrypt strings with constant length as well, does the resultant encrypted string will always have the same length?


Solution

  • That depends on what you mean by 'the same length'.

    The same length as the original string: generally no; the original string will be padded to a multiple of the cipher block-length. Check padding modes for details.

    The same length every time you encrypt: yes; as long as you stick to the same mode and padding the encrypted output will have the same length.