How to Crafting a private and also Public Key
For a separate Blogpost, I need to generate a Public Key. So before we can generate a Public Key, we must generate a Private key. Let me first introduce the key types and let me tell s.th. about the advantages about this.
What is a public and private key?
The Public and private keys are fundamental components of asymmetric encryption, in a widely used cryptographic system. In this system, each user has a pair of keys: a public key that is shared openly, and a private key that is kept confidential.
The public key is used for encryption, allowing anyone to send encrypted messages to the key owner. However, only the corresponding private key can decrypt these messages. This ensures secure communication and data exchange in various online transactions, such as secure email communication, digital signatures, and online banking.
The advantage of using public-key cryptography lies in its ability to establish secure communication channels without the need for both parties to share a secret key beforehand. This eliminates the challenges associated with key distribution in symmetric-key systems and enhances the overall security of digital interactions.
Public key infrastructure (PKI) further extends the utility of public and private key pairs by providing a framework for managing and validating keys in a secure manner.
In the next short chapters I will introduce you, how I generated a public and private key.
How To generate the Private Key
For generating the privaste key, we must install openssl. Better is to use any WSL System
In this you must install then openssl (for example on my ubuntu image)
apt-get install openssl
Then you can create the certificate, please pay attention to get onto the shared drive like c. So go to /mnt/c to access the c-Drive from Windows. while you changed the location, you will execute the follwowing command
openssl genrsa -out privatekey.pem 2048
This generates this output
After that you have your own private key. The content from the pem-File look like this
No I'm not crazy, this key I generated only for demo purpose ;).
Generate the public key
You can now create the public key with this. That's not a big deal, this can be done with the following command:
openssl rsa -in privatekey.pem -outform PEM -pubout -out publickey.pem
The result looks like this
Now you have two files
- privatekey.pem
- publickey.pem
Conslusion
This Blogpost gives you a small and simple step-by-step manual to create a public key. So with this, you can e.g. sign your blog posts or add the publickey to your Github account. So now your content can be identified with your public key.