Security is one of the important concepts in technology as data privacy is one of the serious concerns in today’s time. When transmitting data from one location to another it’s good practice to encrypt data as it prevents tampering/accessing of data in between.

What are the private keys and public keys?

Public and private keys are not really keys but rather are large prime numbers that are mathematically related to each other. If something is encrypted by the public key then it can be only decrypted by its private key pair.

Generally, the public key is shared freely whereas, the private key belongs to a single user.

Usage of private-public key pair

The use of private-public cryptography is done in asymmetric cryptography. It’s used to transmit data in client-server and peer-to-peer architectures. It’s also used to create Digital Signatures.
There are various standards used for encryption during the generation of private-public key pairs like RSA, DSA, ECDSA with variable Key Sizes.

How to generate key pairs?

You can use tools like OpenSSH or any online website to generate key pairs.

Use Case of Private-public key pair

Let’s take Bob as a Sender user who wants to send mail to Alice who is the Receiver user. Primarily Bob takes Alice’s public key and encrypts his message and sends it to Alice. Now Alice uses her private key to decrypt Bob’s message. Similarly, when Alice wants to reply to the message to Bob’s message she will take Bob’s public key to send a message and Bob will use his private key to decrypt the message.

Pro Tip: Exceptional Use Case

Let’s say you need to verify the data has come from the right server. You reverse the use case where you share your public key with the server. The server encrypts data with your public key. This way you can decrypt data with your private key.