I am a software developer, not a cryptologist.

I like the idea of perfect secrecy and would like to use a one-time pad (OTP) to encrypt/decrypt files up to, say, 50Mb. Is there a way that I can use random number generators and seeds to do this, rather than creating the (very large) pad in advance?

For example, if I used a CSPRNG to create two numbers, then used the first number to seed a (predictable) PRNG, and the second number to determine which number in the sequence to use as the first in the pad, would this still give me perfect secrecy?


This is a standard concept in cryptography, and it is called a stream cipher.

It doesn't give ‘perfect’ secrecy, which is a red herring, but it is the modern standard for how to do cryptography—for example, your web browser is almost certainly using exactly this principle right now to talk to the crypto.stackexchange.com web server, using either AES-GCM or ChaCha/Poly1305, which are authenticated ciphers built out of stream ciphers.

Much more important: Use an authenticated cipher so that a forger can't modify your messages in transit, which can sometimes—like in OpenPGP's EFAIL—have the consequence of losing confidentiality too.


No, it won‘t be anything near perfect secrecy. You cannot prove a stream cipher to be theoretically secure without using a TRNG. The secrecy of your stream cipher completely relies on the stream generator. A stream cipher that uses a TRNG is what‘s called a One Time Pad - that‘s by definition. While CSPRNGs are able to give you good secrecy too, one can no longer speak of perfect secrecy in terms of information theory.

If you don‘t want to send your encrypted files over the internet, using a CSPRNG will be fine though. Otherwise use a block cipher like AES to profit from integrity check mechanisms.

  • 1
    $\begingroup$ Using a block cipher like AES does nothing on its own to provide integrity. There's much more to an authenticated cipher than using a block cipher. $\endgroup$ – Squeamish Ossifrage Oct 27 '19 at 15:08

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.