Also, see:
What is a message digest?
What is a cipher?
This is known as public key cryptography and also known as asymmetric cryptography. Two keys (key pairs) are used one for encrypting the data and one for decrypting the data. The keys are called Public Key and Private Key. The public key can be shared, anyone can encrypt data using the public key, but only the receiver can decrypt the data using the private key.
In the diagram, there are two stick men, called From and To. From has a copy of To's public key, so he can encrypt the data, send it to To, and when To gets it, he owns the private key and can decrypt the data From has sent.
As the name suggests the private key is never disseminated, only the owner should be in possession of it.
If you are familiar with using SSH it uses this form of encryption when it does public key authentication.
A good write up on public key cryptography can be found on this wiki link: https://en.wikipedia.org/wiki/Public-key_cryptography