Is there a way to encrypt a pdf with 128AES using only preinstalled ubuntu software of software from main repository? I noticed that exproting from libre office into pdf (one possibility) encrypts it whith a week encryption. Is there a way to to it e.g. using qpdf?

  • Using a qpdf it is possible to chose user and owner password. I am a totally new to ubuntu and I want just to set a password which prevents the pdf to be opened. – Emma Jul 31 '16 at 19:05

QPDF is capable of encrypting a file with 256-bit encryption keys and AES (or the default RC4 with 40, 128 or 256 bit key lengths). The relevant information and command line options are in the QPDF manual.

  • Thank you for the information I checked the manual several times now but I am not sure what to type into the terminal, could you please provide a simple example how to do it? – Emma Jul 31 '16 at 23:26
  • @Emma it looks like you just need to set the key length to 128 and then add the --use-aes=y flag e.g. qpdf --encrypt <user-password> <owner-password> 128 --use-aes=y -- somefile.pdf somefile_encrypted.pdf where <user-password> and <owner-password> are passwords of your choice. – steeldriver Aug 1 '16 at 23:12
  • Very strange. I tried encrypting a file with the command qpdf --encrypt test123 test123 256 -- input.pdf encrypted.pdf. It produces a file encrypted.pdf that can be correctly decrypted with qpdf --password=test123 --decrypt encrypted.pdf decrypted.pdf however, when I try to directly open encrypted.pdf with evince or okular and I'm asked for the password, I input test123 but it says that the password is wrong... – Immanuel Weihnachten Jan 3 '17 at 11:41
  • 2
    That's because Evince doesn't support AES yet, see this bug: bugzilla.gnome.org/show_bug.cgi?id=726598. Also, here is a list of different encryption methods corresponding to different PDF versions: pdflib.com/knowledge-base/pdf-password-security/encryption. – Anatoli Apr 23 '17 at 17:43

After installing qpdf, you can encrypt pdf with password of your choice from command line in the following way.

qpdf --encrypt test123 test123 40 -- doc_without_pass.pdf doc_with_pass.pdf

Where test123 is both the user and owner password

To decrypt the pdf file you can use the following

qpdf --password=test123 --decrypt doc_with_pass.pdf doc_without_pass2.pdf

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.