Skip to content

Commit ad70c82

Browse files
authored
Merge 525a7d5 into 7765aa3
2 parents 7765aa3 + 525a7d5 commit ad70c82

8 files changed

+396
-64
lines changed

.banditrc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ skips:
22
# Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
33
# => OK, we don't care though
44
- B101
5+
# B305:blacklist - Use of insecure cipher mode cryptography.hazmat.primitives.ciphers.modes.ECB.
6+
# Need to bypass this check because the PDF specification demands the use of ECB mode on one of the encryption algorithms
7+
- B305

docs/Encryption.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ If no permission is specified it will default to `all()`.
8181

8282
## Encryption method ##
8383

84-
There are 3 available encryption methods:
84+
There are 4 available encryption methods:
8585

8686
* `NO_ENCRYPTION`
8787
Data is not encrypted, only add the access permission flags.
@@ -90,7 +90,10 @@ There are 3 available encryption methods:
9090
Default PDF encryption algorithm.
9191

9292
* `AES_128`
93-
Encrypts the data with AES algorithm. Requires the `cryptography` package.
93+
Encrypts the data with 128 bit key AES algorithm. Requires the `cryptography` package.
94+
95+
* `AES_256`
96+
Encrypts the data with 256 bit key AES algorithm. Requires the `cryptography` package.
9497

9598
```python
9699
from fpdf import FPDF

fpdf/annotations.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ def __init__(
5252
self.f_t = Name(field_type) if field_type else None
5353
self.v = value
5454
self.f = sum(flags)
55-
self.contents = PDFString(contents) if contents else None
55+
self.contents = PDFString(contents, encrypt=True) if contents else None
5656
self.a = action
5757
self.dest = dest
5858
self.c = f"[{color[0]} {color[1]} {color[2]}]" if color else None
59-
self.t = PDFString(title) if title else None
60-
self.m = PDFDate(modification_time) if modification_time else None
59+
self.t = PDFString(title, encrypt=True) if title else None
60+
self.m = PDFDate(modification_time, encrypt=True) if modification_time else None
6161
self.quad_points = (
6262
pdf_list(f"{quad_point:.2f}" for quad_point in quad_points)
6363
if quad_points

0 commit comments

Comments
 (0)