If Nobody Does It, Do It Yourself - pdf-encrypt-lib
As some of you may know, I have had the good fortune in recent times of meeting many different people from around the world through the Monero community - and one of them is Anhdres, who spoke at Monerokon this year as well. Following his now somewhat legendary Hooks-and-Loops talk from the year before, Anhdres once again found words I consider genuinely wise, and I am paraphrasing here:
If you think something ought to be done but nobody has tackled it yet, then do it yourself, damn it. Do not be afraid of how good or bad the outcome will be - because even if it turns out terribly, it can still serve as the spark that makes someone else say: I can do that better! Either way, a win.
My first JavaScript Library
I had never published a JavaScript library before. Oh, scratch that - I just published my first JavaScript library. Maybe someone will come along and do it better, but after admittedly time-limited research I had found nothing comparable, and so I built on the work of Andrew Dillon, Marked and Digital Bazaar, Inc. and created pdf-encrypt-lib.
What matters is that the library is open source and should be understood as nothing more than a starting shot - something for you to build on and take further. As always, a project like this comes without promises and without guarantees, but if you find something useful in it, that is already a win.
What Does It Do
pdf-encrypt-lib adds password protection to PDFs, and manages PDFs that already have passwords. But behind the simple “password on, done” lies a complex standard known as ISO 32000, and many PDF libraries, in JavaScript or otherwise, simply do not support it at all, or only half-heartedly.
pdf-lib, one of the more popular JavaScript libraries for creating and editing PDFs, has left encryption entirely out of scope, although and it is a long-standing open feature request that has never been addressed. pdf-encrypt-lib is my attempt to close that gap. It applies AES-256, which is the same encryption standard used in VPNs and banking systems, directly to the PDF object model, with the intention that the result opens in every spec-compliant reader, from Adobe Acrobat to a modern browser.
Browser is the key word here, because my motivation to build this library came directly from developing the PDFfile Manager, my newest browser tool - one that in this form only became possible with pdf-encrypt-lib.
Why Not on npm Yet
What still remains is a publication on npm. Since the code has not yet undergone peer review, and cryptography is a sensitive matter that should not flow casually into a critical project via a quick npm install, I decided at this point to publish the library only on GitHub and Codeberg for now. This is meant to prevent uncritical mass consumption, well even if it means acknowledging that my little browser tool will probably never reach the masses. But things come as they come.
Cheers Alexander
Write a comment