A public key as the name suggests is public i.e it can be shown to all without compromising our security.
What can we use a Public Key For:
- For encryption a message which you want that only your friend will be able to decrypt using his/her private key.
- For verifying signature
A private key as the name suggests must be kept private.
What can we use private key For
- For decrypting the encrypted message which your friend had encrypted using your public key.
- For signing a message.
For example, if Bob wants to send sensitive data to Alice, and wants to be sure that only Alice may be able to read it, he will encrypt the data with Alice's Public Key. Only Alice has access to her corresponding Private Key and as a result is the only person with the capability of decrypting the encrypted data back into its original form.
As only Alice has access to her Private Key, it is possible that only Alice can decrypt the encrypted data. Even if someone else gains access to the encrypted data, it will remain confidential as they should not have access to Alice's Private Key.
