January 2019
Beginner to intermediate
372 pages
11h 17m
English
The example uses the RSA packages in the Python PyCryptodome library. The following packages are imported for RSA key generation and the encryption and decryption operations:
from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP
A 2048-bit RSA key is created using the generate method from the RSA package. The public key is exported from this generated key and made public. The key object should be kept secret. A cipher object is created using the public key, and encryption is performed on the message using this object:
message = "plaintext for RSA"
key = RSA.generate(2048)
public = key.publickey()
cipher = PKCS1_OAEP.new(public)
cipher_text = cipher.encrypt(message.encode()) print("Data is ...Read now
Unlock full access