I am trying to make a pseudo-random number generator so that I can use it in a synchronous stream cipher for encrypting plain text. I want it to generate numbers which are as random as possible.

What are good elements that my algorithm must have in order to do so?

This is for an interschool science competition.

  • 2
    $\begingroup$ My recommendation would be to look at the papers behind existing stream ciphers (e.g., Salsa20), and see what they do. $\endgroup$ – Stephen Touset Oct 29 '14 at 18:56
  • $\begingroup$ Sponge construction over a suitable permutation fits the bill, as it has well defined and analyzed security properties $\endgroup$ – Richie Frame Oct 30 '14 at 4:39
  • $\begingroup$ Depends on goals. $\;$ For conformance to industry standards and speed on modern CPUs with AES in hardware, the AES-CTR recommendation of that answer is good. $\;$ For performance or security in other CPUs, I like the first comment. $\;$ For a CSPRNG with internals suitable for visualization, I would consider Trivium. $\endgroup$ – fgrieu Nov 1 '14 at 10:43

There are two answers, really depending on your specifications and how your generator will be evaluated.

If all you need is to have a PRNG with statistically excellent random, but really don't care about predictability or cryptographic considerations, go for something simple like a Mersenne Twister.

If you actually need some effective stream-cipher, look up on existing ciphers. Yet again, I'd go for something simple, like using an AES in CTR.

Note: If you intend to use your solution for any real usage crypto, then by all means please read papers & think about using an existing solution, yours will most likely not be error-proof in the implementation

| improve this answer | |
  • 2
    $\begingroup$ The question mentions use in a synchronous stream cipher, and interschool science competition; this, and topicality on Crypto.SE, implies cryptographic considerations matter. By the answer's admission, it rules out the Mersenne Twister. $\endgroup$ – fgrieu Nov 1 '14 at 10:15

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.