Skip to content

Commit

Permalink
Merge branch 'main' into encrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Jul 2, 2023
2 parents ac82785 + 8963a57 commit a7cfdb4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# CHANGELOG

## Version 3.12.0, 2023-07-02

### 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)

[Full Changelog](https://github.com/py-pdf/pypdf/compare/3.11.1...3.12.0)

## Version 3.11.1, 2023-06-25

### Bug Fixes (BUG)
Expand Down
14 changes: 10 additions & 4 deletions docs/user/encryption-decryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
## Encrypt

> ⚠️ WARNING ⚠️: pypdf only implements [RC4 encryption](https://en.wikipedia.org/wiki/RC4).
> ⚠️ WARNING ⚠️: pypdf uses by default [RC4 encryption](https://en.wikipedia.org/wiki/RC4)
> if you ommit the "algorithm" parameter.
> This encryption algorithm is insecure. The more modern and secure AES
> encryption is not implemented. pypdf can only decrypt, but not encrypt with
> AES.
> encryption requires [`pycryptodome`](https://pypi.org/project/pycryptodome/) to be installed.
Add a password to a PDF (encrypt it):

Expand All @@ -23,13 +23,19 @@ for page in reader.pages:
writer.add_page(page)

# Add a password to the new PDF
writer.encrypt("my-secret-password")
writer.encrypt("my-secret-password", algorithm="AES-256")

# Save the new PDF to a file
with open("encrypted-pdf.pdf", "wb") as f:
writer.write(f)
```

We recommend using `AES-256-R5`:

* Using the [Advanced Encryption Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) encryption
* with a key size of 256 bit


## Decrypt

Remove the password from a PDF (decrypt it):
Expand Down
2 changes: 1 addition & 1 deletion pypdf/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.11.1"
__version__ = "3.12.0"

0 comments on commit a7cfdb4

Please sign in to comment.