When Files Ask for a Password: A Developer's Solution
Alexandr

Alexandr @tabuna

About: I'm an application developer who loves creating concise and efficient web apps.

Location:
Russia Lipetsk 🌳
Joined:
May 8, 2020

When Files Ask for a Password: A Developer's Solution

Publish Date: Mar 12
2 2

In my online world, everything was simple—a login and password were all it took: familiar, secure, and convenient.

The Challenge

Then I stumbled upon a parallel reality: password-protected files like PDF, DOC, ZIP, and more. This wasn’t a rare glitch but a widespread practice in some industries, reminiscent of the floppy disk era. My program, built for modern interactions, would freeze at the sight of such files, bluntly declaring:

"Sorry, we don’t work with these things."

I wasn’t willing to accept this limitation or force users to change long-standing habits. The solution was clear: empower the system to handle these files.

The Journey

PDFs:

I began with PDFs—the cornerstone of document workflows. After testing several PHP libraries from GitHub, which worked until confronted with “quirky” PDFs (errant line breaks or documents that cheekily included /encrypt twice), I discovered qpdf. This external tool reliably handled even the most exotic PDFs.

Office Files:

With .DOCX files, the process was relatively smooth. But the venerable .DOC? Some companies cling to it like a cherished relic, and PHP libraries for this format are scarce. Eventually, msoffcrypto-tool proved to be a true lifesaver.

Archives:

Since I was already integrating external programs via Symfony/Process, I turned to the time-tested 7-Zip for handling archives.

Introducing Lumos

Thus was born Lumos—a cohesive library combining all these tools to effortlessly handle password-protected files. The project is available on GitHub. I’m not expecting accolades or pull requests; I just hope it makes another developer’s life a little easier.


Have you ever encountered password-protected files?

Comments 2 total

  • david duymelinck
    david duymelinckMar 13, 2025

    I haven't encountered password protected documents that needed to be processed.
    But I like the legwork you did!

    • Alexandr
      AlexandrMar 18, 2025

      Thanks! I hadn’t encountered this before either, but it turns out that in many cases, it's a legal or regulatory requirement.

Add comment