How to encrypt a short string and keep the length secret I need to encrypt relatively short strings (generally less than 100 characters). If possible, I want to avoid leaking the length of these strings. How can I do that?

The thing that came to my mind is to pad the text to 1 KiB with random data, separating the content from the padding with a 0x00 byte. Is this a good idea?
Instead of saving the padding length as rossum explained, you can also put a length encoding in front of your plain text. A standardized way to do this would be DER encoding (which uses a dynamic number of length bytes), but in your case you could also use a 2 byte short. Then just add 00h bytes padding up to X times the block size, and encrypt using a cipher without padding.

The advantage is that during decryption you can simply discard the bytes, and you don't need no unpadding mechanism, just discard any bytes behind the plain text.

This method is used e.g. in the PKCS#11 standard (for hardware tokens).