If Crypto can't be found, try to import Cryptodome

This commit is contained in:
Frédéric Perrin 2021-10-16 21:29:22 +01:00 committed by Florian Bach
parent 89dcaf75c1
commit aca0157004
2 changed files with 22 additions and 8 deletions

View File

@ -5,19 +5,26 @@
Helper library with code needed for Adobe stuff.
'''
from Crypto import Random
from uuid import getnode
import os, hashlib, base64
import urllib.request, ssl
from Crypto.Cipher import AES
from datetime import datetime, timedelta
from lxml import etree
import rsa
from Crypto.PublicKey import RSA
from Crypto.Hash import SHA
try:
from Crypto import Random
from Crypto.Cipher import AES
from Crypto.PublicKey import RSA
from Crypto.Hash import SHA
except ImportError:
# Debian (and Ubuntu) ship pycryptodome, but not in its compatible mode with pycrypto
# If `Crypto` can't be found, try under pycryptodome's own namespace
from Cryptodome import Random
from Cryptodome.Cipher import AES
from Cryptodome.PublicKey import RSA
from Cryptodome.Hash import SHA
from oscrypto import keys
from oscrypto.asymmetric import dump_certificate, dump_private_key, dump_public_key

View File

@ -2,9 +2,16 @@ from lxml import etree
import base64
import os, locale, platform
from Crypto.PublicKey import RSA
from Crypto.Util.asn1 import DerSequence
from Crypto.Cipher import PKCS1_v1_5
try:
from Crypto.PublicKey import RSA
from Crypto.Util.asn1 import DerSequence
from Crypto.Cipher import PKCS1_v1_5
except ImportError:
# Debian (and Ubuntu) ship pycryptodome, but not in its compatible mode with pycrypto
# If `Crypto` can't be found, try under pycryptodome's own namespace
from Cryptodome.PublicKey import RSA
from Cryptodome.Util.asn1 import DerSequence
from Cryptodome.Cipher import PKCS1_v1_5
try:
from libadobe import addNonce, sign_node, sendRequestDocu, sendHTTPRequest