Skip to content
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

ENH: Add AES support for encrypting PDF files #1918

Merged
merged 1 commit into from
Jul 2, 2023
Merged

Conversation

MartinThoma
Copy link
Member

  • PdfWriter.encrypt: Add 'algorithm' parameter
  • PdfWriter: Add _encryption property
  • PdfWriter: Add _encrypt_entry property

This change was made in another PR to avoid merge conflicts / get it merged soon. Full credit for the work goes to exiledkingcc in #1816

* PdfWriter.encrypt: Add 'algorithm' parameter
* PdfWriter: Add _encryption property
* PdfWriter: Add _encrypt_entry property

This change was made in another PR to avoid merge conflicts /
get it merged soon. Full credit for the work goes to exiledkingcc
who did all of the work in #1816

Co-authored-by: exiledkingcc <exiledkingcc@gmail.com>
@codecov
Copy link

codecov bot commented Jun 25, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.56 🎉

Comparison is base (7b357c7) 92.83% compared to head (fb5d21d) 93.39%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1918      +/-   ##
==========================================
+ Coverage   92.83%   93.39%   +0.56%     
==========================================
  Files          34       34              
  Lines        7058     7040      -18     
  Branches     1389     1389              
==========================================
+ Hits         6552     6575      +23     
+ Misses        359      312      -47     
- Partials      147      153       +6     
Impacted Files Coverage Δ
pypdf/_encryption.py 94.96% <ø> (+17.40%) ⬆️
pypdf/_writer.py 88.44% <100.00%> (-0.18%) ⬇️

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MartinThoma MartinThoma merged commit 71be38b into main Jul 2, 2023
@MartinThoma MartinThoma deleted the 1816/aes-support branch July 2, 2023 13:20
MartinThoma added a commit that referenced this pull request Jul 2, 2023
New Features (ENH):
-  Add AES support for encrypting PDF files (#1918, #1935, #1936, #1938)
-  Add page deletion feature to PdfWriter (#1843)

Bug Fixes (BUG):
-  PdfReader.get_fields() attempts to delete non-existing index "/Off" (#1933)
-  Remove unused objects when cloning_from (#1926)
-  Add the TK.SIZE into the trailer (#1911)
-  add_named_destination() maintains named destination list sort order (#1930)
@xilopaint
Copy link
Contributor

I can't understand. Wasn't AES encryption already supported?

@MartinThoma
Copy link
Member Author

Decryption was supported, but not encryption.

@xilopaint
Copy link
Contributor

Will pypdf.PdfWriter.encrypt use AES by default from now on?

@MartinThoma
Copy link
Member Author

Not until pypdf==4.0.0. Using AES requires pycryptodome. That means if I change the default behavior, it would be a breaking change.

But with pypdf==4.0.0 I definitely want to make it the default as using the RC4 encryption is insecure.

@xilopaint
Copy link
Contributor

So will Pycryptodome be a mandatory dependency?

@MartinThoma
Copy link
Member Author

No, Pycryptodome is not mandatory and will stay optional.

However, if you want to use modern encryption, you will need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants