mirror of
https://github.com/r4sas/PBinCLI
synced 2025-08-31 16:12:02 +00:00
Fix pycryptodome support when pycrypto is not available
This commit is contained in:
parent
b40f48295a
commit
869cf130a4
@ -20,6 +20,10 @@ try:
|
|||||||
else:
|
else:
|
||||||
from Crypto.Random import get_random_bytes
|
from Crypto.Random import get_random_bytes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
try:
|
||||||
|
from Cryptodome.Cipher import AES
|
||||||
|
from Cryptodome.Random import get_random_bytes
|
||||||
|
except ImportError:
|
||||||
PBinCLIError("Unable import pycryptodome")
|
PBinCLIError("Unable import pycryptodome")
|
||||||
|
|
||||||
|
|
||||||
@ -120,8 +124,15 @@ class Paste:
|
|||||||
|
|
||||||
|
|
||||||
def __deriveKey(self, salt):
|
def __deriveKey(self, salt):
|
||||||
|
try:
|
||||||
from Crypto.Protocol.KDF import PBKDF2
|
from Crypto.Protocol.KDF import PBKDF2
|
||||||
from Crypto.Hash import HMAC, SHA256
|
from Crypto.Hash import HMAC, SHA256
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
try:
|
||||||
|
from Cryptodome.Protocol.KDF import PBKDF2
|
||||||
|
from Cryptodome.Hash import HMAC, SHA256
|
||||||
|
except ImportError:
|
||||||
|
PBinCLIError("Unable import pycryptodome")
|
||||||
|
|
||||||
# Key derivation, using PBKDF2 and SHA256 HMAC
|
# Key derivation, using PBKDF2 and SHA256 HMAC
|
||||||
return PBKDF2(
|
return PBKDF2(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user