{"_id":"@pdfsmaller/pdf-decrypt","_rev":"2-7e40ef72f80f2d0b3a0eadda6722141b","name":"@pdfsmaller/pdf-decrypt","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@pdfsmaller/pdf-decrypt","version":"1.0.0","keywords":["pdf","decryption","pdf-decryption","pdf-decrypt","pdf-unlock","AES-256","AES","RC4","128-bit","256-bit","password-removal","pdf-security","cloudflare","edge","workers","browser","pdf-lib","pdfsmaller"],"author":{"url":"https://pdfsmaller.com","name":"PDFSmaller.com","email":"hello@pdfsmaller.com"},"license":"MIT","_id":"@pdfsmaller/pdf-decrypt@1.0.0","maintainers":[{"name":"smither777","email":"ericpaolosmith@gmail.com"}],"homepage":"https://pdfsmaller.com","bugs":{"url":"https://github.com/smither777/pdf-decrypt/issues"},"dist":{"shasum":"99374555a83ab03368089cffd7ce26fb4454d805","tarball":"https://registry.npmjs.org/@pdfsmaller/pdf-decrypt/-/pdf-decrypt-1.0.0.tgz","fileCount":12,"integrity":"sha512-I8mfWAWCtTUqt8sL/Zqveu5YdFDuqLi4jzHSnMDSdf9TukC8NCwu5o5pwnzS6hf8Gvn7LRjOV2pri7LBM4Is5Q==","signatures":[{"sig":"MEUCIEqb+icFkNhm9oCKidugX7YBJux60mCvFQGo7n/qnjW8AiEA/YQ5AQWPUJeDUdW7Znw/0RygiCkWyQU7hpVkz3ymWpo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":91781},"main":"dist/index.js","type":"commonjs","types":"dist/index.d.ts","module":"dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"aabe1caa78c33c350963c675a297042fe28a10e0","scripts":{"test":"node test.js","build":"node build.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"smither777","email":"ericpaolosmith@gmail.com"},"repository":{"url":"git+https://github.com/smither777/pdf-decrypt.git","type":"git"},"_npmVersion":"11.8.0","description":"Full-featured PDF decryption with AES-256 and RC4 support. Companion to @pdfsmaller/pdf-encrypt. Powers PDFSmaller.com's PDF unlock tool.","directories":{},"_nodeVersion":"24.7.0","_hasShrinkwrap":false,"devDependencies":{"pdf-lib":"^1.17.1","@pdfsmaller/pdf-encrypt":"^1.0.0"},"peerDependencies":{"pdf-lib":"^1.17.1"},"_npmOperationalInternal":{"tmp":"tmp/pdf-decrypt_1.0.0_1772014180515_0.93814021931295","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@pdfsmaller/pdf-decrypt","version":"1.0.1","description":"Full-featured PDF decryption with AES-256 and RC4 support. Companion to @pdfsmaller/pdf-encrypt. Powers PDFSmaller.com's PDF unlock tool.","type":"commonjs","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"node build.js","test":"node test.js","prepublishOnly":"npm run build"},"keywords":["pdf","decryption","pdf-decryption","pdf-decrypt","pdf-unlock","AES-256","AES","RC4","128-bit","256-bit","password-removal","pdf-security","cloudflare","edge","workers","browser","pdf-lib","pdfsmaller"],"author":{"name":"PDFSmaller.com","email":"hello@pdfsmaller.com","url":"https://pdfsmaller.com"},"homepage":"https://pdfsmaller.com","repository":{"type":"git","url":"git+https://github.com/smither777/pdf-decrypt.git"},"bugs":{"url":"https://github.com/smither777/pdf-decrypt/issues"},"license":"MIT","engines":{"node":">=18.0.0"},"peerDependencies":{"pdf-lib":"^1.17.1"},"devDependencies":{"pdf-lib":"^1.17.1","@pdfsmaller/pdf-encrypt":"^1.0.0"},"gitHead":"c2c328a71be852f0d3e4bb10f5be6262ef3cc524","_id":"@pdfsmaller/pdf-decrypt@1.0.1","_nodeVersion":"24.7.0","_npmVersion":"11.8.0","dist":{"integrity":"sha512-UO5KyC+jvcXPTuxfTcEDODHBqO5+YFyuYz/f8tQfiRw5hqZTYTh0ea72OjGw6kuYEUiCyT+A/Ymg2A948Vwx0w==","shasum":"286888309edd7a89494cc457405ac495354adda8","tarball":"https://registry.npmjs.org/@pdfsmaller/pdf-decrypt/-/pdf-decrypt-1.0.1.tgz","fileCount":12,"unpackedSize":91863,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCgKC6ijklKbfYEMEg1aO7tk/icnG+SH61Pb9aqM3PiwwIgYURNso6PjiAmpkq5g6dnzMmqd8yMLGwX7/LSH4n+Os8="}]},"_npmUser":{"name":"smither777","email":"ericpaolosmith@gmail.com"},"directories":{},"maintainers":[{"name":"smither777","email":"ericpaolosmith@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pdf-decrypt_1.0.1_1772014800950_0.8567887099340976"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-25T10:09:40.428Z","modified":"2026-02-25T10:20:01.255Z","1.0.0":"2026-02-25T10:09:40.660Z","1.0.1":"2026-02-25T10:20:01.113Z"},"bugs":{"url":"https://github.com/smither777/pdf-decrypt/issues"},"author":{"name":"PDFSmaller.com","email":"hello@pdfsmaller.com","url":"https://pdfsmaller.com"},"license":"MIT","homepage":"https://pdfsmaller.com","keywords":["pdf","decryption","pdf-decryption","pdf-decrypt","pdf-unlock","AES-256","AES","RC4","128-bit","256-bit","password-removal","pdf-security","cloudflare","edge","workers","browser","pdf-lib","pdfsmaller"],"repository":{"type":"git","url":"git+https://github.com/smither777/pdf-decrypt.git"},"description":"Full-featured PDF decryption with AES-256 and RC4 support. Companion to @pdfsmaller/pdf-encrypt. Powers PDFSmaller.com's PDF unlock tool.","maintainers":[{"name":"smither777","email":"ericpaolosmith@gmail.com"}],"readme":"# @pdfsmaller/pdf-decrypt\n\nFull-featured PDF decryption with **AES-256** and **RC4** support. Built for browsers, Node.js 18+, Cloudflare Workers, and Deno.\n\nCompanion to [@pdfsmaller/pdf-encrypt](https://www.npmjs.com/package/@pdfsmaller/pdf-encrypt). Powers [PDFSmaller.com](https://pdfsmaller.com)'s [Unlock PDF](https://pdfsmaller.com/unlock-pdf) tool.\n\n## Features\n\n- **AES-256 decryption** (V=5, R=6) — PDF 2.0 standard\n- **RC4 40/128-bit decryption** (V=1-2, R=2-3) — legacy support\n- **User + Owner passwords** — accepts either password to decrypt\n- **Batched async decryption** — processes thousands of objects without browser freeze\n- **Web Crypto API** — no native dependencies, works everywhere\n- **Lightweight** — ~18KB total (crypto + decryption logic)\n- **Zero dependencies** — only `pdf-lib` as a peer dependency\n- **TypeScript types** included\n\n## Installation\n\n```bash\nnpm install @pdfsmaller/pdf-decrypt pdf-lib\n```\n\n## Quick Start\n\n```javascript\nimport { decryptPDF } from '@pdfsmaller/pdf-decrypt';\nimport fs from 'fs';\n\nconst pdfBytes = fs.readFileSync('encrypted.pdf');\nconst decrypted = await decryptPDF(new Uint8Array(pdfBytes), 'my-password');\nfs.writeFileSync('decrypted.pdf', decrypted);\n```\n\n## API\n\n### `decryptPDF(pdfBytes, password)`\n\nDecrypt a password-protected PDF. Supports both AES-256 and RC4 encryption — the algorithm is detected automatically.\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `pdfBytes` | `Uint8Array` | The encrypted PDF file as bytes |\n| `password` | `string` | The user or owner password |\n\n**Returns:** `Promise<Uint8Array>` — The decrypted PDF bytes\n\n**Throws:**\n- `\"This PDF is not encrypted\"` — if the PDF has no encryption dictionary\n- `\"Incorrect password\"` — if neither user nor owner password matches\n- `\"Unsupported encryption\"` — if the encryption version is not supported\n\n### `isEncrypted(pdfBytes)`\n\nCheck if a PDF is encrypted without attempting to decrypt it.\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `pdfBytes` | `Uint8Array` | The PDF file as bytes |\n\n**Returns:** `Promise<{ encrypted: boolean, algorithm?: 'AES-256' | 'RC4', version?: number, revision?: number, keyLength?: number }>`\n\n## Examples\n\n### Decrypt with Auto-Detection\n\n```javascript\nimport { decryptPDF, isEncrypted } from '@pdfsmaller/pdf-decrypt';\n\n// Check encryption type first\nconst info = await isEncrypted(pdfBytes);\nif (info.encrypted) {\n  console.log(`Encrypted with ${info.algorithm}`);\n  const decrypted = await decryptPDF(pdfBytes, password);\n}\n```\n\n### Roundtrip with @pdfsmaller/pdf-encrypt\n\n```javascript\nimport { encryptPDF } from '@pdfsmaller/pdf-encrypt';\nimport { decryptPDF } from '@pdfsmaller/pdf-decrypt';\n\n// Encrypt\nconst encrypted = await encryptPDF(pdfBytes, 'secret');\n\n// Decrypt\nconst decrypted = await decryptPDF(encrypted, 'secret');\n```\n\n### Browser Usage\n\n```html\n<input type=\"file\" id=\"pdf-input\" accept=\".pdf\" />\n<input type=\"password\" id=\"password\" placeholder=\"Enter password\" />\n<button id=\"decrypt-btn\">Decrypt</button>\n\n<script type=\"module\">\n  import { decryptPDF } from '@pdfsmaller/pdf-decrypt';\n\n  document.getElementById('decrypt-btn').addEventListener('click', async () => {\n    const file = document.getElementById('pdf-input').files[0];\n    const password = document.getElementById('password').value;\n    const pdfBytes = new Uint8Array(await file.arrayBuffer());\n\n    try {\n      const decrypted = await decryptPDF(pdfBytes, password);\n\n      // Download\n      const blob = new Blob([decrypted], { type: 'application/pdf' });\n      const url = URL.createObjectURL(blob);\n      const a = document.createElement('a');\n      a.href = url;\n      a.download = 'decrypted.pdf';\n      a.click();\n    } catch (e) {\n      alert(e.message);\n    }\n  });\n</script>\n```\n\n## Supported Encryption\n\n| Algorithm | PDF Version | Key Length | Status |\n|-----------|-------------|-----------|--------|\n| AES-256 (V=5, R=6) | 2.0 (ISO 32000-2) | 256-bit | Supported |\n| RC4 (V=2, R=3) | 1.4+ (ISO 32000-1) | 128-bit | Supported |\n| RC4 (V=1, R=2) | 1.1+ | 40-bit | Supported |\n| AES-128 (V=4, R=4) | 1.6+ | 128-bit | Not yet supported |\n\n## Comparison with pdf-decrypt-lite\n\n| Feature | pdf-decrypt | pdf-decrypt-lite |\n|---------|-------------|-----------------|\n| AES-256 | Yes | No |\n| RC4 128-bit | Yes | Yes |\n| RC4 40-bit | Yes | Yes |\n| Batched async | Yes | No (sync only) |\n| Size | ~18KB | ~8KB |\n| Use case | Full decryption | RC4-only, minimal |\n\nChoose `pdf-decrypt-lite` if you only need RC4 and want the smallest possible bundle. Choose `pdf-decrypt` for full AES-256 + RC4 support.\n\n## Related Packages\n\n| Package | Description |\n|---------|-------------|\n| [@pdfsmaller/pdf-encrypt](https://www.npmjs.com/package/@pdfsmaller/pdf-encrypt) | Full encryption — AES-256 + RC4 (companion to this package) |\n| [@pdfsmaller/pdf-encrypt-lite](https://www.npmjs.com/package/@pdfsmaller/pdf-encrypt-lite) | Lightweight RC4-only encryption (~7KB) |\n| [@pdfsmaller/pdf-decrypt-lite](https://www.npmjs.com/package/@pdfsmaller/pdf-decrypt-lite) | Lightweight RC4-only decryption (~8KB) |\n\n## License\n\nMIT — [PDFSmaller.com](https://pdfsmaller.com)\n","readmeFilename":"README.md"}