Encryption
Reads what exists, writes only what is worth writing.
Reading protected files
JavaScript
const doc = await Pdf.open(bytes, { password: 'hunter2' })The empty password is always tried first, which opens the many documents that are encrypted with no user password purely to set permission bits. RC4 and every revision from 2 to 6 are read, because legacy files exist.
Writing protection
JavaScript
const weaknesses = await doc.protect({ userPassword: 'open-me', ownerPassword: 'owner-only', strength: 'aes-256',})AES-256 is the only strength written. RC4 and revision 5 are read for compatibility and never produced, because writing them would be shipping a known weakness to somebody who asked for protection.
weaknesses names anything about the request that is weaker than it looks: a short password, an empty user password, permissions that no reader is obliged to respect.
Permissions
Reported, never enforced
The
/P bits say what a conforming reader should allow. Rasura reports them and acts on none of them. Enforcing them would claim a security property the format does not have: anyone with the file and any library can ignore them.