Encrypting a PDF with 256-bit AES protects its contents from anyone who does not have the password. The encryption is only as strong as the settings you choose, so after encrypting you should verify the encryption level rather than assuming the command did what you asked.
What you need
- qpdf installed
- A PDF to encrypt
- A strong user password and a strong owner password, kept separately
Step 1: Encrypt the PDF
Run qpdf –encrypt USERPASSWORD OWNERPASSWORD 256 — input.pdf output.pdf to encrypt the file with 256-bit AES. The first password is the user password, the second is the owner password.
Step 2: Verify the encryption level
Run qpdf –show-encryption output.pdf and read the reported encryption level. Confirm it says 256-bit AES and not a weaker level.
Step 3: Test the passwords
Open the encrypted file as a reader with the user password and confirm it opens. Then check that the owner password is needed to change the permissions.
Worked example: synthetic encryption check on a 3-page contract
The table below is a synthetic example. It shows the expected result of encrypting a PDF; no file was encrypted.
| Check | Expected | Found |
|---|---|---|
| Encryption level | 256-bit AES | 256-bit AES |
| Opens with user password | Yes | Yes |
| Opens without password | No | No |
| Page count | 3 | 3 |
Expected result (UNTESTED). the file is encrypted with 256-bit AES, opens with the user password, refuses to open without one, and keeps all 3 pages. Store the owner password separately from the user password. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Encryption protects the file only while the password is secret; a weak password makes strong encryption useless.
- The user and owner passwords must be different; using the same password for both defeats the permission controls.
- An encrypted PDF cannot be indexed or searched until it is decrypted, so do not encrypt files that must be searchable.
