
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@pdfsmaller/pdf-encrypt-lite
Advanced tools
Ultra-lightweight PDF encryption (7KB) with real RC4 128-bit encryption. Built for edge environments like Cloudflare Workers. Powers PDFSmaller.com's encryption.
Ultra-lightweight PDF encryption library (only 7KB!) with real RC4 128-bit encryption
Built by PDFSmaller.com - Try our free online PDF tools with this encryption built-in!
When building PDFSmaller.com, we needed real PDF encryption that worked within Cloudflare Workers' 1MB limit. Every existing solution was 2-20MB+ in size. We were told it was "impossible" to implement proper PDF encryption in such a small package.
We proved them wrong.
This library is the exact encryption engine that powers PDFSmaller.com's Protect PDF tool - battle-tested on thousands of PDFs daily.
npm install @pdfsmaller/pdf-encrypt-lite pdf-lib
import { encryptPDF } from '@pdfsmaller/pdf-encrypt-lite';
import { PDFDocument } from 'pdf-lib';
// Basic usage
const encryptedPdfBytes = await encryptPDF(existingPdfBytes, 'user-password');
// With separate owner password
const encryptedPdfBytes = await encryptPDF(
existingPdfBytes,
'user-password',
'owner-password'
);
// Full example
async function protectPDF() {
// Load your PDF
const existingPdfBytes = await fetch('document.pdf').then(res => res.arrayBuffer());
// Encrypt it with pdf-encrypt-lite
const encryptedBytes = await encryptPDF(
new Uint8Array(existingPdfBytes),
'secret123',
'owner456'
);
// Save the encrypted PDF
const blob = new Blob([encryptedBytes], { type: 'application/pdf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'protected.pdf';
a.click();
}
Perfect for:
See it in action at PDFSmaller.com/protect-pdf - our free online tool uses this exact library to encrypt PDFs directly in your browser. No uploads, no server processing, just pure client-side encryption!
We built custom implementations of:
Total size: ~7KB 🤯
| Library | Size | Real Encryption | Edge Compatible |
|---|---|---|---|
| pdf-encrypt-lite | 7KB ✅ | ✅ | ✅ |
| node-forge | 1,700KB | ✅ | ❌ |
| crypto-js | 234KB | ✅ | ⚠️ |
| pdf-lib alone | 0KB | ❌ | ✅ |
We welcome contributions! This library powers PDFSmaller.com, so we maintain high standards for security and compatibility.
MIT License - Use it freely in your projects!
Built with ❤️ by PDFSmaller.com - Your free PDF toolkit
If this library helps you, check out our other free PDF tools:
export default {
async fetch(request, env) {
const formData = await request.formData();
const file = formData.get('pdf');
const password = formData.get('password');
const pdfBytes = new Uint8Array(await file.arrayBuffer());
const encrypted = await encryptPDF(pdfBytes, password);
return new Response(encrypted, {
headers: { 'Content-Type': 'application/pdf' }
});
}
}
⭐ Star this repo if it helps you!
Built because we needed it. Shared because you might too.
PDFSmaller.com - Free PDF Tools That Actually Work™
FAQs
Ultra-lightweight PDF encryption (7KB) with real RC4 128-bit encryption. Built for edge environments like Cloudflare Workers. Powers PDFSmaller.com's encryption.
The npm package @pdfsmaller/pdf-encrypt-lite receives a total of 2,985 weekly downloads. As such, @pdfsmaller/pdf-encrypt-lite popularity was classified as popular.
We found that @pdfsmaller/pdf-encrypt-lite 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.