Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

First of all, I would like to note that I am not building my own crypto. I am simply curious and would like to learn.

What I am wondering is this: if we are worried about randomness of something like a one time pad, why don't we run the pad through a compression process (like bzip) to eliminate any patterns? Wouldn't we essentially then be working with data guaranteed not to have patterns (at least over the chunk size of the compression algorithm)?

Is anyone doing this? Would it even work? If not, why not?

share|improve this question
A bziped file starts 42h 5Ah; not good for a keystream! There are a lot of other redundancy, including markers of compression settings, and at least one error detection code. More generally, for many existing compression algorithms, the output is distinguishable from random even if the input is not; often, the distinguisher can simply be: decompresses without error. – fgrieu Jul 28 '14 at 4:37
up vote 4 down vote accepted

A one time pad (OTP) should by definition not have any patterns. An entropy source can have patterns, but an OTP by definition should consist of pure random bits.

In general you can create something that is close to a true random number generator by applying a cryptographic hash function over the output of an entropy source. According to NIST you should however provide twice the entropy within the input compared with the output. A cryptographic hash function is often referred to as a compression function.

Such a compression function should however not be confused with the underlying compression functions used for creating zip or bzip (etcetera) archives. Those are fully reversible compression functions, and will therefore only add some complexity, not security.

So there is probably somebody doing this, but no, it won't work.

share|improve this answer
This is what I love about StackExchange: a good answer with a clear explanation. Many thanks. I learned something today. – Bobby Newmark Jul 27 '14 at 19:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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