If I have a program that take a string to give me the ciphertext, nothing stored, using the same keys. The ciphertext is a base64. Can I figure out the type of encryption by the amount of characters in the base64 string?

Is it true that, 17 character string gives:

  • 16 Bytes = MD5,
  • 20 Bytes = SHA-1,
  • 24 Bytes = 3/DES,
  • 32 Bytes = AES?

If that is true, what is the range of bytes for each encryption by specific encrypted text length?

I'm a beginner, so please tell me if there are any other notes or hints...


Ciphertext should be indistinguishable from random. The same goes for hash functions such as MD5 and SHA1. But as you already found out, this is only for the given output domain: the set of all possible ciphertext or hashes. It depends on the algorithm how much variation there is in ouput domains:

  • for hash functions the output size is part of the definition of the hash function, e.g. 160 bits for SHA-1;
  • for RSA - an asymmetric cipher primitive - the ciphertext is within 0 and N, the public modulus of the key used;
  • for DES, triple DES and AES, which are block ciphers, the size of the output is exactly the block size.

Now if we focus on the block ciphers: block ciphers are used in a mode of operation. Without the mode of operation the output of AES is not secure; in other words, AES needs a mode of operation to be used as generic, secure cipher.

It depends on the mode of operation what the size of the ciphertext will be. For instance for CTR mode the output is the same size as the plaintext - it doesn't need to be padded. For CBC some kind of padding is required and the output will always be a multiple of the block size.

So where does that leave us? Well, basically we cannot tell all that much from the ciphertext itself. We can tell that ciphertext is certainly not the result of some kind of ciphers.

For instance a 6 byte ciphertext cannot be the output of a cryptographic hash function and is not the output of 3DES or AES in CBC mode. This means that the analyst can skip these algorithms when trying to find the right one from a particular set.

On the other hand the same 6 byte ciphertext can be the result of AES or triple DES in CTR mode. Which one cannot be determined by the ciphertext alone.

So the encryption mode can often not be determined that way. Note that the encryption method is generally considered known by the attacker. It is not considered a secret by the parties using the cryptography.

This is known as Kerckhoffs principle. This is basically because the method of cryptography is only one static known fact, part of the protocol description. Hiding the cipher only makes the life of an attacker slightly harder; relying on secret cipher algorithms has resulted in spectacular failures in the past.

Note that for your question base 64 encoding really doesn't matter. You simply reverse the encoding before analyzing the ciphertext.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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