Skip to content
WorldofPDFs

What an encrypted PDF actually is, and how to open one

Encryption in a PDF is narrower and more interesting than a padlock icon suggests: it scrambles the content and leaves the skeleton in plain view.

The short answer

An encrypted PDF is one whose content, the text, images, fonts and strings on its pages, has been scrambled with a key derived from a password, using RC4 or AES. A viewer needs the right password, or an empty one if only permissions were set, to rebuild the key and decrypt the content. The file's structure stays readable either way.

That last part surprises people, and it explains a good deal about how encrypted PDFs behave.

What encryption covers, and what it leaves alone

A PDF is a collection of numbered objects: dictionaries, arrays, numbers, names, strings and streams. Streams carry the heavy content, such as a page's drawing instructions, an embedded image or a font. Strings carry smaller pieces of text, such as a form value, a bookmark title or the author's name.

PDF encryption applies to strings and streams, and only those. The older schemes give each object its own key, derived from the file key and the object's number; AES-256 uses the file key directly with a fresh random starting value for every string and stream. Either way, identical content in two places does not produce identical ciphertext.

Everything else stays in the clear: the object numbers, the cross-reference table that says where each object sits, the dictionary keys, and the names and numbers inside them. Anyone opening an encrypted file in a text editor can see that it has, say, 14 pages, what size they are, that it contains images and fonts and form fields, and which encryption scheme it uses. What they cannot see is what any of it says.

Document metadata is a special case. The newer XML metadata stream can be deliberately left unencrypted, so that search tools can index a file's title and author without the password. Whether it is depends on a flag set when the file was encrypted.

RC4, AES-128 and AES-256: the security handler revisions

The method lives in an encryption dictionary referenced from the file's trailer. Most files use the standard security handler, which is the password-based scheme every viewer supports, and it has gone through several revisions. A file records its revision number, and the revision decides both the cipher and how the key is derived from the password.

  • Revision 2: RC4 with a 40-bit key. Dating from the format's early years, and short enough to be broken by exhaustive search on modern hardware regardless of the password.
  • Revision 3: RC4 with keys up to 128 bits, and a key derivation that repeats its MD5 hashing to slow down guessing.
  • Revision 4: introduced crypt filters, allowing either 128-bit RC4 or AES-128, and the option to leave metadata unencrypted.
  • Revision 5: AES-256 with a SHA-256 based key derivation. An interim scheme that was superseded quickly, because its password check was cheap to attack.
  • Revision 6: AES-256, standardised in PDF 2.0, with a deliberately expensive key derivation that mixes SHA-256, SHA-384 and SHA-512 rounds with AES. This is the one to use today.

Two passwords, one key

A PDF can carry a user password, needed to open it, and an owner password, which governs permissions such as printing and copying. The difference between them is covered in detail elsewhere; what matters here is how they relate to encryption.

Both passwords lead to the same file key. A file with only an owner password is still encrypted, but its user password is empty, so every viewer can derive the key without asking you for anything. Its contents are scrambled in the file and unscrambled the moment it opens. The permission flags are then honoured, or not, by the viewer, because the viewer already has everything it needs to show and copy the content.

A file with a user password is different in kind. Without that password there is no key, and without the key there is no content, only the skeleton described above. Against revision 6 with a long password, no tool recovers that content in any practical amount of time, which is the point.

How to open an encrypted PDF

If it asks for a password, you need that password; there is no legitimate shortcut. Enter it in any PDF reader and the file opens normally. If you will open it often, decrypt a copy so it stops asking: open it with the password, then save it without encryption.

Doing that properly means actually decrypting the streams and writing them back as plain content, not rendering each page to an image. World of PDF's Remove Password tool decrypts the file in your browser using an implementation of the standard security handler, revisions 2 to 6, so text stays text and the password never leaves your device.

If it opens without a password but refuses to print or copy, it is owner-locked, and Unlock PDF removes those restrictions. For the other direction, Encrypt PDF applies AES-256 encryption (security handler revision 5, so pick a long password) with separate choices for printing, copying and editing. It renders each page to an image first, so the text in the output is not selectable.

One warning for anyone editing encrypted files with other software: a library that parses past the encryption dictionary without decrypting the streams can save a file with the right page count and nothing visible on the pages. If a tool offers to edit an encrypted PDF without asking for its password, check the output before deleting the original.

Frequently asked questions

What does it mean when a PDF is encrypted?

Its text, images, fonts and strings are scrambled with a key derived from a password. The page count and structure remain visible, but the content cannot be read without the key.

Is a PDF with only print and copy restrictions encrypted?

Yes, but with an empty user password, so any viewer can derive the key and open it. The restrictions are enforced by the viewer rather than by the encryption.

Which PDF encryption is the most secure?

AES-256 with security handler revision 6, combined with a long password. Revision 2, which uses 40-bit RC4, can be broken regardless of the password.

Can you open an encrypted PDF without the password?

Not if it has a user password and modern encryption. If it opens without asking, it only has an owner password, and its restrictions can be removed without one.

Does encryption hide a PDF's metadata?

Usually, but not always. The XML metadata stream can be left unencrypted by design, so a file's title and author may remain readable without the password.

Tools mentioned in this guide