Would merely repeating the same value 8 times be sufficient ? Or is there a more clever approach for doing this ? The 256 bit values would be generated from SHA256 of files.

  • $\begingroup$ use it to see a cryptographic random number generator. $\endgroup$ – user58512 Mar 9 '13 at 14:27
  • $\begingroup$ I think this is the best approach yes. I found msdn.microsoft.com/en-us/library/… which seems to do something pretty close to that. $\endgroup$ – xander Mar 9 '13 at 16:43

Random numbers for cryptography are a tough subject because you need true random numbers and that is a difficult subject!

However, the method you are suggesting is not sufficient whatsoever for cryptographic purposes.

You should have a look at the NIST Recommendation for Random Number Generation Using Deterministic Random Bit Generators.

Also, you might want to have a look at the "Handbook of Applied Cryptography".

Lastly, you might want to learn about DIEHARDER and TESTU01 for testing the quality of your random bits as you need high entropy source.

If this is for non-crypto purpose, you might want to use Keccak - SHA3 to extend the number of bits.


  • $\begingroup$ Thank you so much for your recommendations. I can't use Keccak I think, because there isn't a ready-made Microsoft C# implementation yet. I ended up using msdn.microsoft.com/en-us/library/… giving it the SHA256/SHA512 hash, and getting back 256 random bytes (2048 bits). $\endgroup$ – xander Mar 9 '13 at 16:45
  • $\begingroup$ This needs more thumbs up! got one from me ;-) $\endgroup$ – Namaste Apr 23 '13 at 0:18
  • $\begingroup$ True RNG is a very tricky business and is a really hard area! Thx $\endgroup$ – Amzoti Apr 23 '13 at 0:19

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.