Python magic detects the mime type "application/encrypted" for password protected microsoft office documents. But I am unable to find any information about this mime type on the internet. It is not even listed at https://www.iana.org/assignments/media-types/media-types.xhtml
Is this even a valid mime type?
And if I wanted to check if a file is a protected office document is checking for this mime type a reliable method?
This is the code I am using: magictype is "application/encrypted" after.
import magic
magictype = magic.Magic(mime=True).from_file(filepath)
This is an interesting question, as of 2024 this is still the only relevant search result for "application/encrypted" mime type. I came across this whilst debugging why a customer's file wasn't being accepted by my PHP application.
When testing with file --mime-type -b file.docx, the expected application/vnd.openxmlformats-officedocument.wordprocessingml.document MIME type is returned if the file is password-protected for modification.
However, if it's password-protected for opening, application/encrypted is detected.
I haven't found application/encrypted mentioned anywhere else online, nor any workaround. Maybe the opening/modifying distinction might be helpful to others, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With