
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@pdfsmaller/pdf-encrypt
Advanced tools
Full-featured PDF encryption with AES-256 and RC4 128-bit support. Built for browsers, Node.js, and edge environments. Powers PDFSmaller.com's encryption.
Full-featured PDF encryption with AES-256 and RC4 128-bit support. Built for browsers, Node.js 18+, Cloudflare Workers, and Deno.
Powers PDFSmaller.com's Protect PDF tool.
pdf-lib as a peer dependencynpm install @pdfsmaller/pdf-encrypt pdf-lib
import { encryptPDF } from '@pdfsmaller/pdf-encrypt';
import fs from 'fs';
const pdfBytes = fs.readFileSync('input.pdf');
// AES-256 encryption (default, recommended)
const encrypted = await encryptPDF(new Uint8Array(pdfBytes), 'my-password');
fs.writeFileSync('encrypted.pdf', encrypted);
encryptPDF(pdfBytes, userPassword, options?)| Parameter | Type | Description |
|---|---|---|
pdfBytes | Uint8Array | The PDF file as bytes |
userPassword | string | Password required to open the PDF |
options | object | Optional configuration (see below) |
Returns: Promise<Uint8Array> — The encrypted PDF bytes
| Option | Type | Default | Description |
|---|---|---|---|
ownerPassword | string | same as user | Password for managing permissions |
algorithm | 'AES-256' | 'RC4' | 'AES-256' | Encryption algorithm |
allowPrinting | boolean | true | Allow printing the document |
allowModifying | boolean | true | Allow modifying content |
allowCopying | boolean | true | Allow copying text/images |
allowAnnotating | boolean | true | Allow adding annotations |
allowFillingForms | boolean | true | Allow form filling |
allowExtraction | boolean | true | Allow accessibility extraction |
allowAssembly | boolean | true | Allow document assembly |
allowHighQualityPrint | boolean | true | Allow high-quality printing |
const encrypted = await encryptPDF(pdfBytes, 'user-pass', {
ownerPassword: 'admin-pass',
allowPrinting: true,
allowCopying: false,
allowModifying: false
});
const encrypted = await encryptPDF(pdfBytes, 'password', {
algorithm: 'RC4'
});
<input type="file" id="pdf-input" accept=".pdf" />
<script type="module">
import { encryptPDF } from '@pdfsmaller/pdf-encrypt';
document.getElementById('pdf-input').addEventListener('change', async (e) => {
const file = e.target.files[0];
const pdfBytes = new Uint8Array(await file.arrayBuffer());
const encrypted = await encryptPDF(pdfBytes, 'secret');
// Download
const blob = new Blob([encrypted], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'encrypted.pdf';
a.click();
});
</script>
| Feature | AES-256 | RC4 |
|---|---|---|
| Security | Quantum-resistant | Deprecated, known weaknesses |
| PDF Version | 2.0 (ISO 32000-2) | 1.4+ (ISO 32000-1) |
| Key Length | 256-bit | 128-bit |
| Reader Support | Modern readers | All readers |
| Recommended | Yes | Legacy only |
| Package | Description |
|---|---|
| @pdfsmaller/pdf-decrypt | Full decryption — AES-256 + RC4 (companion to this package) |
| @pdfsmaller/pdf-encrypt-lite | Lightweight RC4-only encryption (~7KB) |
| @pdfsmaller/pdf-decrypt-lite | Lightweight RC4-only decryption (~8KB) |
MIT — PDFSmaller.com
FAQs
Full-featured PDF encryption with AES-256 and RC4 128-bit support. Built for browsers, Node.js, and edge environments. Powers PDFSmaller.com's encryption.
We found that @pdfsmaller/pdf-encrypt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.