The instruction wants them the ciphertext to be the same size as the original message.

The original message is "alicexoxox:bobko0oo0l:popo" I am supposed to use openSSL cli to generate a key in hexadecimal which i did by running: "openssl rand -hex 32"

i then applied the aes ecb command on this message by running: <echo -n "alicexoxox:bobko0oo0l:popo" | openssl enc -aes-256-ecb -K (key from running rand command)>

the output looks way longer than the original message and i want to ask if thats normal or if theres a fix for that


1 Answer 1


AES is a block cipher which is a process that takes as input a fixed number of bits (known as the block size) and outputs the same number of bits. For AES, the block size is 128-bits or 16-bytes.

When used in ECB mode, plaintext is divided into blocks of the appropriate size (16-bytes for AES). When the last piece of plaintext does not have enough bits to fill out the entire block, some additional bits are added to "pad" the message out to a whole number of blocks. There are several padding schemes that can be used, but PKCS#7 is very common.

If your message alicexoxox:bobko0oo0l:popo is treated as an ASCII plaintext, it will be 26-bytes long. When dividing this into AES blocks, we would add 6 bytes of padding to make two blocks in total. These two blocks of 16-bytes are passed into AES and we get out two blocks of ciphertext for a total of 32-bytes.

  • $\begingroup$ So I’m guessing that’s why I got a bad decrypt error when I tried decrypting. I wanted to ask what extra command I would have to add to my current command. I also wanted to ask if I would have to add padding on both encryption and decryption. $\endgroup$
    – pkob1
    Jan 28 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.