How PDF passwords and encryption work
User and owner passwords, permissions, RC4, AES and what unlocking really means
What the open and owner passwords actually do, which parts of a PDF are encrypted, how RC4 gave way to AES-256, why permissions depend on the reader and why a lost password is gone for good.
- By HelpMeJPG editorial team
- Published
- Updated
- 9 min read
On this page
Quick answer: A PDF can carry two passwords: the open (user) password, from which the key that encrypts the file's text and images is derived, and the owner password, which lifts permission flags – printing, copying, editing – that only compliant readers honour. Modern files use AES-256 as defined in ISO 32000-2; older ones use AES-128 or RC4. Nothing in the file stores the password itself, which is why a lost password cannot be recovered, and "unlocking" a PDF legitimately means entering a password you know and saving an unencrypted copy.
Two passwords with two different jobs
The PDF standard security handler recognises two passwords, and the confusion between them causes most of the surprises people have with "protected" files.
| Open (user) password | Owner (permissions) password | |
|---|---|---|
| What it does | Required to decrypt and display the document | Grants full access and lifts the permission restrictions |
| Who needs it | Every reader of the file | Only someone who wants to change what is allowed |
| If it is absent | Anyone can open the file | Most tools set it equal to the user password |
| What it protects | The content itself | The permission settings |
When both are set and different, a reader prompts for a password; entering the user password opens the document with the restrictions in force, entering the owner password opens it with everything allowed. When only an owner password is set, the file opens without any prompt. Here the content is encrypted with a key derived from an empty user password, so any reader can compute the key and display everything. Owner-only protection controls behaviour, not secrecy. If the aim is to keep the contents from people who should not see them, there must be an open password.
The Protect PDF tool follows this model: an open password, an optional separate owner password, a set of permission switches and a choice of encryption strength. If you set only an owner password, it warns you that anyone will be able to open the file.
What permissions really control
The permission flags live in a single integer in the encryption dictionary. The standard defines bits for printing (with a separate bit for high-quality printing), modifying the document, copying or extracting text and graphics, adding annotations and filling form fields, extracting content for accessibility, and assembling the document – inserting, rotating or deleting pages.
Two facts put these in perspective. First, the flags are instructions to software, not properties of the data. A reader that follows the specification greys out the Print button when printing is disallowed; a reader that does not, or a program written to ignore the flags, simply prints. Nothing cryptographic stops it, because the content has already been decrypted for display. Second, anyone who knows the owner password can switch the flags off, and anyone who knows either password can save an unencrypted copy with no flags at all. Permissions are useful for signalling intent – "please do not alter this" – and for stopping casual misuse, and they should never be mistaken for security. The accessibility flag deserves a note of its own: the protect tool always leaves it on, so screen readers can reach the text of a protected document even when copying is disallowed.
What is actually encrypted
The standard security handler does not encrypt the whole file. It encrypts the strings and streams inside it – page content streams, embedded images and fonts, annotation text, form field values, bookmark titles and the text of the document information dictionary – each with a key derived from the file key and the object's number. The skeleton of the file stays in the clear: object numbers, dictionary keys, the page tree, the encryption dictionary itself and the cross-reference structure.
This has consequences you can observe. A protected file still reveals how many pages it has and what size they are, which is why the PDF page counter and the PDF metadata viewer can report a count and flag the encryption without a password, while the title, author and content stay hidden until one is entered. Not every producer encrypts everything it should: a tool that encrypts streams but leaves strings alone leaks the author, title, comments and form values in plain text, whereas the protection here encrypts both, as the specification requires. Separately, the standard allows the XMP metadata stream to be left unencrypted so that indexing software can read it – a deliberate choice that can expose more than intended, and worth checking in a file you did not produce yourself.
From RC4 to AES-256
Encryption in PDF has been revised several times, and the revision number stored in the file tells a reader which algorithm and which password-handling rules to apply.
| Introduced | Revision | Algorithm | Notes |
|---|---|---|---|
| PDF 1.1 | 2 | RC4, 40-bit key | Searchable by brute force on ordinary hardware; obsolete |
| PDF 1.4 | 3 | RC4, up to 128-bit key | Security rests entirely on the password; RC4 itself is deprecated |
| PDF 1.5–1.6 | 4 | Crypt filters: RC4 or AES-128 | AES-128 (AESV2) is the first modern option |
| Vendor extension to 1.7 | 5 | AES-256, simple password hash | An interim scheme whose fast hash made password guessing easier; superseded |
| ISO 32000-2 (PDF 2.0) | 6 | AES-256, hardened password hash | The current standard; passwords are Unicode, up to 127 bytes |
Revision 6 did two things. It adopted AES with a 256-bit key in CBC mode – the Advanced Encryption Standard as specified by NIST – and it changed how passwords are turned into keys: the password is normalised (so that the same characters typed on different systems produce the same bytes), then run through an iterated hashing procedure that is deliberately expensive, which slows down anyone trying passwords by the million.
The protect tool writes revision 6 AES-256 by default and offers AES-128 for readers too old to support it. The reasonable advice today is simple: use AES-256 unless you know a recipient's software cannot open it, and remember that the algorithm is never the weak point. A 256-bit key derived from a six-character password is as strong as the six characters.
Certificates, DRM and other handlers
Passwords are not the only way to protect a PDF, and the alternatives are easy to confuse with them because the viewer's prompt looks similar.
Public-key (certificate) encryption uses a different security handler. The file key is encrypted separately for each intended recipient using their public certificate, and each recipient's software decrypts it with their private key. There is no password to type; access is tied to possessing a key, and a sender can address a document to several people at once. The standard builds this on the Cryptographic Message Syntax used for secure email.
Rights management and DRM schemes go further still: the file names a proprietary handler that contacts a licensing server or a plug-in to obtain the key, so that access can be revoked, time-limited or tied to a device. E-book protection works this way.
Neither of these is a password scheme, and the Unlock PDF tool recognises and rejects both with an explanation. Opening such files requires the issuing software, the matching certificate or the licence – not a password, and not a different password tool.
Why a lost password cannot be recovered
The file does not contain the password. It contains values computed from the password – in revision 6, hashes that let a reader verify a candidate password, and copies of the file key encrypted under keys derived from each password. Checking a password therefore works, but reversing the process does not: there is no operation that turns the stored values back into the characters that produced them.
The only remaining approach is guessing, and the arithmetic decides whether that is feasible. A 40-bit RC4 key can be searched exhaustively in a reasonable time, which is why revision 2 files offer no real protection regardless of password. For AES, exhaustive search of the key is out of the question, so guessing moves to the password: short or common passwords fall quickly to dictionary and brute-force attacks, long random passphrases do not, and revision 6's slow hashing makes every guess more expensive. This is what "password recovery" software does – it guesses – and it succeeds only against weak passwords or weak revisions. Nothing on this site attempts it. If a strong password is genuinely lost, the realistic remedy is to ask whoever produced the document for another copy.
What "unlock" legitimately means
To unlock a PDF is to open it with a password you know and save a copy that no longer asks for one. Any compliant reader can do this through its Save or Print dialog, and the unlock tool does the same thing in the browser: it checks that the file really is encrypted, decrypts it with the user or owner password you enter – either works, as the standard intends – and writes a plain file with its pages, forms, bookmarks and attachments intact. All restrictions go with the password, so if you need permissions without an open password, run the result through the protect tool again with only an owner password.
Unlocking is also a prerequisite for most other operations: protected files have to be opened before they can be merged, compressed or split, and the result is unprotected – why PDF compression sometimes fails and how to merge PDF files both note this. Protect the finished document afterwards rather than the parts.
Try it: Unlock PDF with a password you know, and Protect PDF to add AES-256 encryption to the finished file.
What encryption does and does not protect
Encryption protects a document at rest and in transit. It does not protect it from the people you give the password to. Once a recipient has opened the file, they can print it, photograph the screen, copy the text by hand or save an unencrypted copy, whatever the permission flags say. A password is a lock on the envelope, not a leash on the letter.
That framing settles most practical questions. Share the password through a different channel from the file. Use a passphrase rather than a word. And decide separately how the recipient will be trusted once the envelope is open; safe handling of confidential PDFs deals with the rest of that question, including the metadata and hidden content a password does nothing about, and preparing PDFs for email covers sending a protected file.
Frequently asked questions
Can I remove a PDF password without knowing it?
No. The file stores values derived from the password, not the password itself, and a correctly encrypted document cannot be decrypted without the key those values protect. Recovery software merely guesses passwords and succeeds only when they are short or the file uses an obsolete 40-bit scheme. The unlock tool here requires the user or owner password and never attempts to guess.
If I set only an owner password, is my document secure?
No. An owner-only file opens for anyone without a prompt, because the content is encrypted under an empty user password that every reader can compute. The owner password only controls the permission flags, which compliant readers honour and others ignore. To keep the content confidential you must set an open password.
Should I choose AES-128 or AES-256?
AES-256 as defined in PDF 2.0, unless you know the recipient uses software released before it was supported. Both are sound ciphers; the practical difference is that the 256-bit scheme uses a deliberately slow password hash that makes guessing far more expensive. In either case, the strength of the protection is the strength of your password.
Sources and further reading
About the author
HelpMeJPG editorial teamEditorial team
The people who build and maintain the HelpMeJPG tools. Guides are written from the tools' own behaviour and the standards they implement, and are revised whenever a tool changes.