Introduction
In Public-Key Cryptography you have two keys: a public key and a private key.
As the names indicates the public key is for everyone eyes and the private is to be hidden and is personal.
Encryption with the PRIVATE key, also called Signature
Encryption with you private key, is not very secret, since one can decrypt it with the public key. And since it is public, anyone can do that. So what good is that? Verification. When you can successfully decrypt it, you can be sure of, that this data has not been tampered and can only be originated from the person that holds the private key.
This encrypted is called Signature.
Encryption with the PUBLIC key
This is what you usually call encryption, since it can only be decrypted with the private key.
Example
Generate a public and private key.
Java code