# Protect a PDF with AES-256 passwords

Encrypt a PDF with AES-256 Standard security, set document-open and owner passwords, and review preservation evidence for the protected copy.

Secure a PDF

[Protect a PDF in the browser](/browser/protect-pdf/) [Read the security guide](/docs/pdf/security/)

Protection summary

**Input**

PDF and passwords

**Output**

AES-256 protected PDF

**Package**

[OfficeIMO.Pdf on NuGet](https://www.nuget.org/packages/OfficeIMO.Pdf)

**Runs on**

Browser-local WebAssembly or .NET

**Microsoft Office**

Not required

**License**

MIT

Password encryption controls opening and permissions; it is not a digital signature or trust assertion.

[Browse all PDF workflows](/pdf/)

Practical steps

## Create an AES-256 password-protected PDF

Set separate user and owner credentials, rewrite the document, and verify the protected output.

1. **Select**Choose one PDF that can be rewritten under the current security policy.
2. **Protect**Enter a document-open password and a separate owner password.
3. **Verify**Create the AES-256 output and review encryption and preservation evidence.

Password protection uses the PDF Standard security handler. The user password opens the document; the owner password controls privileged changes and should be stored separately from the delivered file.

## Protect from .NET

```csharp
using OfficeIMO.Pdf;

PdfDocument source = PdfDocument.Load("statement.pdf");
var encryption = new PdfStandardEncryptionOptions("reader-password") {
    OwnerPassword = "owner-password",
    Algorithm = PdfStandardEncryptionAlgorithm.Aes256
};

PdfSecurityMutationResult result = source.Security.Encrypt(encryption);
File.WriteAllBytes("statement.protected.pdf", result.Pdf);
Console.WriteLine(result.PreservationReport.Summary);
```

The mutation result exposes whether the output is encrypted and whether the rewrite preserved the expected document structure. Applications should handle passwords through their normal secret-management policy, not source code or logs.

## Encryption is not signing

Password protection does not identify the publisher, validate document integrity through a certificate, or timestamp a revision. Use the cryptographic signing and validation APIs through `OfficeIMO.Pdf` and `OfficeIMO.Security` when the workflow requires those guarantees.

## API used on this page

- [`PdfDocument`](/api/pdf/officeimo-pdf-pdfdocument/)
- [`PdfSecurityMutationResult`](/api/pdf/officeimo-pdf-pdfsecuritymutationresult/)
- [`PdfStandardEncryptionAlgorithm`](/api/pdf/officeimo-pdf-pdfstandardencryptionalgorithm/)
- [`PdfStandardEncryptionOptions`](/api/pdf/officeimo-pdf-pdfstandardencryptionoptions/)

<!-- PowerForge markdown artifact sha256:8F459A2906039BD82636F2D159A25127F86C6C3E59195128A1DE1C92258EB272 -->
