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

With the same plain text to be encrypted and the same public key, OpenPGP tends to produce a different ciphertext every time I run the encryption operation. Why is this?

share|improve this question
Possible duplicate of Why is "semantically secure" important for cryptosystems? – otus May 30 at 18:12
@otus I half agree with you here. Yes, semantically secure is important, but that doesn't directly explain why/how PGP produces different ciphertext. – Maarten Bodewes May 31 at 14:26

OpenPGP is a hybrid cryptosystem. The actual message is encrypted applying a symmetric cipher like AES with a random session key. This session key again is encrypted using a public/private key cryptography algorithm like RSA. This is mostly because symmetric encryption is much faster than public/private key cryptography, especially for large messages. As the session key is generated randomly, the cryptotext is different each time you encrypt something.

Another reason is that OpenPGP includes timestamps in different packets.

share|improve this answer
See also for that session key. – ott-- May 30 at 17:45
Maybe it is a good idea to point out the idea that PGP should create semantically secure ciphertext (one of the reasons why the session key is created, apart from different recipients of course). – Maarten Bodewes May 31 at 14:28

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.