作为 PyCrypto 的继任者，PyCryptodome 有相当大的潜力。
PyCryptodome is a fork of PyCrypto. It brings the following enhancements with respect to the last official version of PyCrypto (2.6.1)
style (string) – Padding algorithm. It can be ‘pkcs7’ (default), ‘iso7816’ or ‘x923’.
默认就是支持 pkcs7 填充算法的。
It supports Python 2.6 or newer, all Python 3 versions and PyPy.
The installation procedure depends on the package you want the library to be in. PyCryptodome can be used as:
- an almost drop-in replacement for the old PyCrypto library. You install it with:
pip install pycryptodome
In this case, all modules are installed under the Crypto package.
One must avoid having both PyCrypto and PyCryptodome installed at the same time, as they will interfere with each other.
This option is therefore recommended only when you are sure that the whole application is deployed in a virtualenv.
- a library independent of the old PyCrypto. You install it with:
pip install pycryptodomex
In this case, all modules are installed under the Cryptodome package. PyCrypto and PyCryptodome can coexist.
PyCryptodome is not a wrapper to a separate C library like OpenSSL. To the largest possible extent, algorithms are implemented in pure Python. Only the pieces that are extremely critical to performance (e.g. block ciphers) are implemented as C extensions.
Fortunately there is a fork of the project called PyCrytodome that is a drop-in replacement for PyCrypto.
The cryptography package aims to be “cryptography for humans” much like the requests library is “HTTP for Humans”. The idea is that you will be able to create simple cryptographic recipes that are safe and easy-to-use. If you need to, you can drop down to low=level cryptographic primitives, which require you to know what you’re doing or you might end up creating something that’s not very secure.