2023-02-08 15:04:39 -05:00
|
|
|
import types
|
|
|
|
|
2023-02-06 16:52:29 -05:00
|
|
|
from ..compat import functools
|
2023-02-08 15:04:39 -05:00
|
|
|
from ..compat.compat_utils import passthrough_module
|
2023-02-06 16:52:29 -05:00
|
|
|
|
|
|
|
try:
|
|
|
|
import Cryptodome as _parent
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
import Crypto as _parent
|
|
|
|
except (ImportError, SyntaxError): # Old Crypto gives SyntaxError in newer Python
|
2023-02-08 15:04:39 -05:00
|
|
|
_parent = types.ModuleType('no_Cryptodome')
|
2023-02-06 16:52:29 -05:00
|
|
|
__bool__ = lambda: False
|
|
|
|
|
2023-02-07 21:44:36 -05:00
|
|
|
passthrough_module(__name__, _parent, (..., '__version__'))
|
2023-02-08 15:04:39 -05:00
|
|
|
del passthrough_module
|
2023-02-06 16:52:29 -05:00
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@functools.cache
|
|
|
|
def _yt_dlp__identifier():
|
|
|
|
if _parent.__name__ == 'Crypto':
|
|
|
|
from Crypto.Cipher import AES
|
|
|
|
try:
|
|
|
|
# In pycrypto, mode defaults to ECB. See:
|
|
|
|
# https://www.pycryptodome.org/en/latest/src/vs_pycrypto.html#:~:text=not%20have%20ECB%20as%20default%20mode
|
|
|
|
AES.new(b'abcdefghijklmnop')
|
|
|
|
except TypeError:
|
|
|
|
return 'pycrypto'
|
|
|
|
return _parent.__name__
|