1 from ..compat
.compat_utils
import passthrough_module
4 import Cryptodome
as _parent
7 import Crypto
as _parent
8 except (ImportError, SyntaxError): # Old Crypto gives SyntaxError in newer Python
9 _parent
= passthrough_module(__name__
, 'no_Cryptodome')
10 __bool__
= lambda: False
12 del passthrough_module
15 AES
= PKCS1_v1_5
= Blowfish
= PKCS1_OAEP
= SHA1
= CMAC
= RSA
= None
17 if _parent
.__name
__ == 'Cryptodome':
18 from Cryptodome
import __version__
19 from Cryptodome
.Cipher
import AES
, PKCS1_OAEP
, Blowfish
, PKCS1_v1_5
20 from Cryptodome
.Hash
import CMAC
, SHA1
21 from Cryptodome
.PublicKey
import RSA
22 elif _parent
.__name
__ == 'Crypto':
23 from Crypto
import __version__
24 from Crypto
.Cipher
import AES
, PKCS1_OAEP
, Blowfish
, PKCS1_v1_5
# noqa: F401
25 from Crypto
.Hash
import CMAC
, SHA1
# noqa: F401
26 from Crypto
.PublicKey
import RSA
# noqa: F401
27 except (ImportError, OSError):
28 __version__
= f
'broken {__version__}'.strip()
31 _yt_dlp__identifier
= _parent
.__name
__
32 if AES
and _yt_dlp__identifier
== 'Crypto':
34 # In pycrypto, mode defaults to ECB. See:
35 # https://www.pycryptodome.org/en/latest/src/vs_pycrypto.html#:~:text=not%20have%20ECB%20as%20default%20mode
36 AES
.new(b
'abcdefghijklmnop')
38 _yt_dlp__identifier
= 'pycrypto'