Understanding public-key cryptography is as simple as difficult to implement by programmers like me . Ok, This is also knows as **asymmetric cryptography** which is based on mathematically generated two keys. One key is used to encrypt data and other to decrypt it and **only other key can decrypt it**.

*Obviously there is one computer program to encrypt and other to decrypt using these keys .*

So their is a program which generates two key based on a really large random number. One is know as public key and other is know as private key.

**Public key is the key which is distributed publically** to encrypt data so that any one who want to encrypt the data he/she can encrypt it but encrypted data can be decrypted only with private key even person who encrypted it can not decrypt it.

*So private key is never shared with unauthorised party.*

#### Examples to generate public/private key pairs

C# example

Java Example