diff --git a/pypdf/_crypt_providers/_cryptography.py b/pypdf/_crypt_providers/_cryptography.py index b8515cd44..f5537612d 100644 --- a/pypdf/_crypt_providers/_cryptography.py +++ b/pypdf/_crypt_providers/_cryptography.py @@ -29,7 +29,13 @@ from cryptography import __version__ from cryptography.hazmat.primitives import padding -from cryptography.hazmat.primitives.ciphers.algorithms import AES, ARC4 +from cryptography.hazmat.primitives.ciphers.algorithms import AES + +try: + # 43.0.0 - https://cryptography.io/en/latest/changelog/#v43-0-0 + from cryptography.hazmat.decrepit.ciphers.algorithms import ARC4 +except ImportError: + from cryptography.hazmat.primitives.ciphers.algorithms import ARC4 from cryptography.hazmat.primitives.ciphers.base import Cipher from cryptography.hazmat.primitives.ciphers.modes import CBC, ECB