# Generate fixed length cipher text from arbitrary length plaintext

Using an encryption algorithm like AES, is it possible to generate a fixed length cipher text no matter how long the plain text becomes?

-
Welcome to Cryptography Stack Exchange. Do you want to be able to decrypt this again? Then it is impossible in general to have a shorter ciphertext than the plaintext. Otherwise this is not called encryption but a "hash" ... it is possible to build a hash function from AES, but not trivial to do so in a secure way. –  Paŭlo Ebermann May 16 '13 at 18:37
yeah my purpose is to encrypt and decrypt both. –  Mitaksh Gupta May 17 '13 at 7:18
Well you could but the solution is a rather ugly one: Pad your plaintext with random data so that all plaintexts are the same size. –  rath May 18 '13 at 1:52

That is quite impossible. Lets assume that such an encryption scheme would exist and assume that it always outputs ciphertexts of length $n$ bits.

Then, because the scheme is assumed to encrypt plaintexts of arbitrary length, it in particular encrypts all plaintexts of length $n+1$ to ciphertexts of length $n$. However, there exist twice as many plaintexts of length $n+1$ than ciphertexts of length $n$. So by the pigeonhole principle there exists at least one ciphertexts that encrypts more than one plaintext. This directly implies, that decryption would be impossible in such a scheme.

-
Okay @Maeher thanks –  Mitaksh Gupta May 16 '13 at 11:38
Simplistically, such a construct would allow for infinitely efficient compression. Want to distribute a 10TB file? Easy! "Encrypt" it with this scheme and it's now only $n$ bits in size. –  Stephen Touset May 16 '13 at 23:56