Encrypt data with AES Generate an RSA key Generate public key and private key Encrypt data with RSA Frequently Asked Questions. > signature = pkcs1_15.new(key).sign(h)Īt the other end, the receiver can verify the signature (and therefore the authenticity of the message) using the matching public RSA key: > key = RSA.import_key(open('public_key.der'). First, install the pycryptodome package, which is a powerful Python library of low-level cryptographic primitives (hashes, MAC codes, key-derivation, symmetric and asymmetric ciphers, digital signatures): pip install pycryptodome RSA Key Generation Now, let's write the Python code. Compiling in Linux Ubuntu Compiling in Linux Fedora Windows (from sources) Documentation PGP verification Compatibility with P圜rypto API documentation Examples.
> key = RSA.import_key(open('private_key.der').read()) The following example shows how a private RSA key (loaded from a file) can be used to compute the signature of a message: > from Crypto.Signature import pkcs1_15 I found a way with a method as efficient and more secure, here is the code (took directly from the PKCS1_v1_5 documentation):