Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

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

I'm using SHA256 to hash the output of an entropy generator to generate random numbers. Is it generally better to treat the output of the entropy generator as single messages and hash each of those separately (internal state is reset), or as a message of unknown length (internal state is preserved)?

share|improve this question

Generally seeds for PRNG's should be mixed in with the internal state using a hash function, and the output should be at least a hash away from the internal state. You could take some hints from the implementation of SHA1PRNG in the Sun JCE or from other hash based PRNG's on how to do this.

You do not want to forget the internal state, because in that case the output is fully dependent on the seed. If there is any problem with a seed, you would have predictable output.

share|improve this answer

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.