How to detect if a Word document is password protected before uploading the file to server?

后端 未结 5 543
余生分开走
余生分开走 2020-12-12 05:57

I am working on a website, which allows users to upload different file formats. We need to restrict the user from uploading password protected files.

Is there a way

5条回答
  •  自闭症患者
    2020-12-12 06:31

    Sorry I'm a bit late to the party here. As I don't yet have 50 reputation I can't comment on Tomasso Belluzo's answer, but as I implemented it I found the following:

    1. To get the prefix I use Encoding.UTF7.GetString
    2. To check for "EncryptedPackage" I use Encoding.Unicode.GetString which obviates the need to remove all the \0s

提交回复
热议问题