# PL/ENCRYPT: Native AES-256 PDF Security Inside Oracle Database
PDF documents often leave the application that created them.
An invoice may be downloaded from APEX, a statement may be emailed to a customer, or a confidential report may be transferred to another system. Once that happens, database permissions no longer protect the document itself.
PDF encryption provides another layer of protection directly inside the file.
Password-protected PDFs can restrict access to authorized users, while permissions can control operations such as printing, copying or document modification.
## AES-256 protection for existing PDFs
PL/ENCRYPT takes an existing, unencrypted PDF stored as an Oracle BLOB and produces a new encrypted PDF BLOB.
It uses the PDF Standard Security Handler with **AES-256, Revision 6 and AESV3 encryption**, including encrypted document metadata.
The PDF can come from anywhere:
– PL/PDF
– Oracle APEX reporting
– another PDF library
– an external reporting system
– an uploaded document
PL/ENCRYPT is independent from the software that originally created the PDF.
## Native PL/SQL — no external PDF engine
One of the main design goals of PL/ENCRYPT is simplicity of deployment.
The complete PDF processing workflow runs inside Oracle Database using **native PL/SQL**.
There is:
– no Java stored procedure
– no external PDF server
– no command-line utility
– no third-party runtime
Oracle `DBMS_CRYPTO` provides the cryptographic primitives, while PL/ENCRYPT handles the PDF encryption structures and document rewrite.
The workflow is simply:
**PDF BLOB → PL/ENCRYPT → AES-256 encrypted PDF BLOB**
## One small PL/SQL API
“`plsql
l_encrypted_pdf := pl_encrypt.setProtection(
p_pdf => l_source_pdf,
p_print_perm => true,
p_modify_perm => false,
p_copy_perm => false,
p_annot_forms_perm => false,
p_user_pass => ‘user-password’,
p_owner_pass => ‘owner-password’
);
“`
The source BLOB remains unchanged. PL/ENCRYPT returns a separate encrypted PDF BLOB.
## Passwords and permissions
The PDF security model distinguishes between a **user password** and an **owner password**.
PL/ENCRYPT can also control whether compliant PDF readers allow:
– printing
– document modification
– copying and content extraction
– annotations and form operations
All permission flags default to `FALSE`, so applications explicitly enable only the operations they require.
These permissions are useful document controls, but they are not a substitute for server-side authorization.
## Encryption is not a digital signature
Encryption and digital signatures solve different problems.
**Encryption protects confidentiality** — who can read the document.
**Digital signatures protect authenticity and integrity** — who signed it and whether it has been changed.
For workflows that also require PAdES signatures, timestamps or long-term validation, PL/SIGN can be used as the signing layer.
PL/ENCRYPT keeps PDF security where the application logic and data already live: **inside Oracle Database, directly from PL/SQL.**
#Oracle #PLSQL #PDF #AES256 #Encryption #DatabaseSecurity #OracleAPEX #PLslash
