Page MenuHomePhabricator

Public | Add Field for Password-Protected Status
Closed, WontfixPublic


Kathryn [[ | suggested need for being able to check password-protected status ]]for PDF, Word, and Excel files.

As a compliance check, all sensitive data files need to be password protected, whether they are PDFs, Excel, or Word files. I need a software that can show me if we missed any files that need to be encrypted/protected, for compliance purposes. I’d love the ability to see both protected AND un-protected files. Most software I’ve come across will only show that protected files in a list format.

Perhaps this could be added for a later version.
IsPasswordProtected Gets whether the Portable Document Format (PDF) document is password-protected.

Word and Excel might require interop with the applications installed on the machine:

Here is a method by examining the file directly from

public static Boolean IsProtected(String file)
    Byte[] bytes = File.ReadAllBytes(file);

    String prefix = Encoding.Default.GetString(bytes.Take(2).ToArray());

    // Zip and not password protected.
    if (prefix == "PK")
        return false;

    // Office format.
    if (prefix == "ÐÏ")
        // XLS 2003
        if (bytes.Skip(0x208).Take(1).ToArray()[0] == 0xFE)
            return true;

        // XLS 2005
        if (bytes.Skip(0x214).Take(1).ToArray()[0] == 0x2F)
            return true;

        // DOC 2005
        if (bytes.Skip(0x20B).Take(1).ToArray()[0] == 0x13)
            return true;

        // Guessing
        if (bytes.Length < 2000)
            return false;

        // DOC/XLS 2007+
        String start = Encoding.Default.GetString(bytes.Take(2000).ToArray()).Replace("\0", " ");

        if (start.Contains("E n c r y p t e d P a c k a g e"))
            return true;

        return false;

    // Unknown format.
    return false;

Event Timeline

Joe created this task.Jun 14 2019, 11:00 AM
Joe created this object in space S5 Public.
Joe triaged this task as Wishlist priority.
Joe created this object with visibility "Public (No Login Required)".
Joe updated the task description. (Show Details)
Joe updated the task description. (Show Details)Jun 14 2019, 11:23 AM
Joe closed this task as Wontfix.Feb 12 2020, 8:27 AM
Joe claimed this task.

A custom program was written for client.