private key and public key code example
Example 1: what is public key
A public key is like an open box with an unbreakable lock.
If someone wants to send you a message, they can place that message
in your public box, and close the lid to lock it. The message can
now be sent, to be delivered by an untrusted party without needing
to worry about the contents being exposed. Once I receive the box,
I'll unlock it with my private key - the only existing key which can
open that box.
Example 2: create public key from private
chmod 400 ~/.ssh/id_rsa
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
Example 3: Generating Public and Private Key
path = Path(__file__).absolute().parent
encryption = Encryption(path, name=('public_key.pem', 'private1.pem'))
encryption.generate_keys()