Je suis en train d'exécuter un programme de base crypto écrit en Python, et même si cela fonctionne correctement sur OS X, je ne peux pas le faire fonctionner sous Windows (3.6/Anaconda installé avec VS 2017) quand j'ai vérifié dans la configuration que je voulais installer Python, et dans une installation binaire 3.4 autonome).Erreur avec cryptographie Python sous Windows
Comme individuellement chaque déclaration d'importation fonctionne dans l'interpréteur, mais dans son ensemble ce programme ne fonctionne pas
from hashlib import sha256
from pbkdf2_ctypes import *
import hmac
import hashlib
import binascii
from os import urandom
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
import getpass
masterpassword = "thisisamasterpassword"
salt = urandom(16)
masterpassword = pbkdf2_hex(masterpassword.encode('utf-8'), salt)
password = masterpassword.decode()
salt = binascii.hexlify(salt)
salt = salt.decode()
print(masterpassword)
Le résultat est:
C:\Users\me\Desktop>py -3.4 masterpassword.py
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pbkdf2_ctypes.py", line 127, in <module>
raise OSError('Library not found')
OSError: Library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "masterpassword.py", line 3, in <module>
from pbkdf2_ctypes import *
File "C:\Python34\lib\site-packages\pbkdf2_ctypes.py", line 153, in <module>
raise ImportError('Cannot find a compatible cryptographic library '
ImportError: Cannot find a compatible cryptographic library on your system
J'ai également installé à la fois un binaire OpenSSL (https://slproweb.com/products/Win32OpenSSL.html) et s'est assuré qu'il fonctionnait sous Anaconda.
Merci beaucoup! J'ai suivi votre première (plus facile, je suppose) solution de copier libeay32 à un nouveau libeay64, qui s'est avéré être dans C: \ ProgramFiles \ Anaconda \ Bibliothèque \ bin pour moi (exécutant le 3.6 qui est venu avec VS 2017). J'ai également remarqué ce test plus tôt où il échouait, mais je ne me sens pas aussi confiant en creusant dans ce code :( –