Encryption novice here so maybe this question makes no sense... Obviously if you know what the clear text is and it decrypts right, you have it. But if someone is running through keys to break the encryption how do they know they have it right? Would you have to check for readable text or can you tell from the math that you have it right? Like the remainder always equals 0 or something.


Blowfish is a block cipher and block ciphers in ECB or CBC require that the length is a multiple of the block size. If this is not the case the last block is padded. There exists several methods for padding. The point is, if the decryption does not result in a correct padding you know that you have decrypted the ciphertext with the wrong key.

You can also analyze the decrypted plaintext with randomness tests. The plaintext of a correctly decrypted ciphertext usually contains much less randomness compared to a plaintext decrypted with a wrong key. If you expect the plaintext to contain

Recently a research project has been announced which is called Honey Encryption. It will be presented at the Eurocrypt conference in Copenhagen this year. The idea is that when encrypted data is decrypted with the wrong key the plaintext that is produced by the decryption algorithm looks plausible. An attacker cannot distinguish between an incorrect but plausible looking plaintext and the correct plaintext. The disadvantage of this approach is that it doesn't seem to work with all plaintexts. It was primarily designed to be used to encrypt credit card numbers or passwords.


I don't know if that holds for blowfish too, but usually the strengths of encryption algorithms is that basically every decryption is a valid decryption. In order to check that the decryption makes sense you would have to check if the text fulfills your expectations.

It is possible that the decryption of some ciphertext results in hello world when you use the password 'foo' and it results in honkey donk if you use the password 'bar'.

So checking for readable text (if this is what you expect) is the right choice. No remainder or so.

  • While this is technically correct of block ciphers themselves, block ciphers are usually used in "modes" that may have some limited error detection. For instance, CBC mode pads each message deterministically; if the padding of the decrypted message doesn't match, this is easy to detect. However, more than $\frac{1}{256}$ of all messages will have valid padding. With authenticated modes like GCM or CCM, the output includes an authentication tag that will only validate if the key, IV, and message are unchanged. This provides an overwhelmingly high assurance that the message is the original. – Stephen Touset Feb 12 '14 at 19:08
  • I agree. For the special case of brute-forcing you don't know if the message is padded at all (constraint). But a valid padding could be 'what you expect'. – fr00tyl00p Feb 12 '14 at 19:13

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.