pycryptodome¶
Crypto.Cipher¶
https://pycryptodome.readthedocs.io/en/stable/src/cipher/cipher.html
Crypto.PublicKey¶
https://pycryptodome.readthedocs.io/en/stable/src/public_key/public_key.html
API principles¶
In [ ]:
Copied!
from Crypto.PublicKey import RSA
# generate random key
key = RSA.generate(2048)
# get key from memory
key = RSA.import_key(open('xxx.pem').read())
# get private key and public key
private_key = key.export_key()
public_key = key.publickey().export_key()
# construct key
key = RSA.construct((n, e, d)) # 注意是一个元组 rsa_components
from Crypto.PublicKey import RSA
# generate random key
key = RSA.generate(2048)
# get key from memory
key = RSA.import_key(open('xxx.pem').read())
# get private key and public key
private_key = key.export_key()
public_key = key.publickey().export_key()
# construct key
key = RSA.construct((n, e, d)) # 注意是一个元组 rsa_components