Creates a new V4 security handler with AES-128 encryption.
Configuration options for the handler.
ProtectedcryptMap of named crypt filters.
ProtectedcryptMapping of content types to crypt filter names.
The encryption dictionary containing all encryption parameters.
Protected OptionaldocumentDocument identifier for key derivation.
Whether to encrypt document metadata.
Protected OptionalmasterDerived master encryption key.
Protected OptionalownerComputed owner key (O value).
Protected OptionalownerOwner password for full access.
ProtectedpasswordUser password for authentication.
Numeric permission flags.
Protected OptionaluserComputed user key (U value).
ProtectedbuildBuilds the numeric permission flags from a PdfPermissions object.
The permissions to encode.
The numeric permission flags.
Checks if metadata encryption is enabled.
True if metadata should be encrypted.
ProtectedcomputeComputes the master encryption key from the password.
The computed master key.
Computes the object-specific encryption key.
OptionalobjectNumber: numberThe PDF object number.
OptionalgenerationNumber: numberThe PDF generation number.
Optionalalgorithm: PdfEncryptionAlgorithmTypeOptional algorithm type for key derivation.
The computed object key.
ProtectedcomputeComputes the owner key (O value) using RC4-128 algorithm.
The computed owner key.
ProtectedcomputeComputes the user key (U value) using RC4-128 algorithm.
The computed user key.
Decodes the numeric permission flags into a PdfPermissions object.
An object with boolean flags for each permission.
Decrypts data using the appropriate crypt filter for the content type.
The type of content being decrypted.
The encrypted data.
OptionalobjectNumber: numberThe PDF object number.
OptionalgenerationNumber: numberThe PDF generation number.
The decrypted data.
Recursively decrypts all strings and streams within an indirect object.
The indirect object to decrypt.
Encrypts data using the appropriate crypt filter for the content type.
The type of content being encrypted.
The data to encrypt.
OptionalobjectNumber: numberThe PDF object number.
OptionalgenerationNumber: numberThe PDF generation number.
The encrypted data.
Recursively encrypts all strings and streams within an indirect object.
The indirect object to encrypt.
ProtectedgetGets an AES-128 cipher for the specified object.
OptionalobjectNumber: numberThe PDF object number.
OptionalgenerationNumber: numberThe PDF generation number.
An AES-128 cipher instance.
Gets a crypt filter by name.
The crypt filter name.
The crypt filter, or undefined if not found.
Gets the crypt filter assigned to a content type.
The content type ('string', 'stream', or 'file').
The assigned crypt filter, or null if none.
Gets the encryption key length in bits.
128 for V2 encryption.
Gets the security handler filter name.
'Standard' for password-based encryption.
Gets the encryption revision number.
4 for V4 encryption.
Gets the encryption version number.
4 for crypt filter-based encryption.
ProtectedinitInitializes the user and owner keys if not already set.
Checks if the handler is ready (has document ID).
True if document ID is set.
Reads encryption parameters and crypt filter definitions from the dictionary.
The encryption dictionary from the PDF.
Recovers the user password from the owner password.
OptionalownerPassword: string | ByteArrayThe owner password.
The recovered user password as a string.
Registers a named crypt filter.
The filter name.
The crypt filter instance.
Assigns a crypt filter to a content type.
The content type.
The crypt filter name.
Sets the master encryption key directly.
The master key to use.
Sets the owner password.
The owner password string or bytes.
Sets the user password.
The user password string or bytes.
Writes the encryption dictionary including crypt filter definitions.
V4 security handler implementing AES-128-CBC encryption with crypt filters. Supports different encryption methods for strings, streams, and embedded files (PDF 1.5).
Example