Is there a form of AES encryption where the cipher text matches the length of the clear text and does not show patterns? I have clear text, usually less than 10 bytes, which contains a few infrequently changing bytes.

Reading: http://lollyrock.com/articles/nodejs-encryption/ I tried aes-256-ctr:


The cipher text is as short as the clear text, which is good.
The cipher text contains patterns, at the positions of the infrequently changing bytes, which is bad.


I tried aes-256-cbc:


The cipher text length is rounded up to the nearest 16 bytes, which is bad.
The cipher text appears random, which is good.


Is there a form of AES encryption where the cipher text matches the length of the clear text and does not show patterns?
What you want is length-preserving encryption, which is a special case of Format-preserving encryption.

A standard mode for achieving this FFX mode, which uses a blockcipher, like AES, in a Feistel network. This mode is relatively complex and slow.

But I strongly recommend using normal authenticated encryption over format preserving encryption whenever possible. Format-preserving encryption always leaks if two plaintexts are identical, whereas semantically secure encryption avoids this leak. It also lacks integrity protection, unlike authenticated encryption.