-
Notifications
You must be signed in to change notification settings - Fork 2.7k
enable password protection (Word) #1019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable password protection (Word) #1019
Conversation
hello, what's is the state of this? still valid pr? i tried to test with master branch but there are some conflicts. |
fix PHPCS errors add documentation add sample
/** | ||
* Password encoder for microsoft office applications | ||
*/ | ||
class PasswordEncoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maartenba @Progi1984 Would it make sense to move this class to the PHPOffice common project? I guess it could be reused in PhpSpreadsheet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense to do, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as @maartenba
Poke @MarkBaker & @PowerKiKi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Progi1984 @maartenba @MarkBaker @PowerKiKi I created a PR in Common for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actually not quite sure how this should/could be used in PhpSpreadsheet...
FYI, the PR: PHPOffice/Common#15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems indeed that pre-2013 excel sheets use a very simplistic password hashing which is completely different.
In more recent specs, it also uses something very similar to what is used in word. Not sure the algorithm is the same though.
https://www.thespreadsheetguru.com/blog/2014/8/20/understanding-excels-password-security-methodology
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PowerKiKi I see you have the pre-2013 hashing implemented already in PhpSpreadsheet/Shared/PasswordHasher, this would be a more modern password hashing mechanism
…/jun-i-corn/PHPWord into feature/EnablePasswordProtection
This pull request will solve #546
It enables PHPWord to create password protected docx-files which MS Word can open and unlock. It was tested on MS Word 2010.
To implement the password protection, we translated the C#-code from https://blogs.msdn.microsoft.com/vsod/2010/04/05/how-to-set-the-editing-restrictions-in-word-using-open-xml-sdk-2-0/
The actual password-hash generation is located in /Writer/Word2007/Part/Settings.php as it is Word-specific and cannot be used for the other writers.
I hope the comments left in the code and the link to the C# source clarify what is happening. But if there are any questions or remarks, feel free to share them.
Cheers, Maria