Our videos have over 5 million views on Youtube! Visit our channel now »
The listings featured on this site are from companies from which this site receives compensation. Read the Advertising Disclosure for more information
Professional Reviews

vpnMentor contains reviews that are written by our community reviewers, and are based on the reviewers' independent and professional examination of the products/services.


vpnMentor is owned by Kape Technologies PLC, which owns the following products: ExpressVPN, CyberGhost, ZenMate, Private Internet Access, and Intego, which may be reviewed on this website.

Affiliate Commissions Advertising

vpnMentor contains reviews that were written by our experts and follow the strict reviewing standards, including ethical standards, that we have adopted. Such standards require that each review will be based on an independent, honest and professional examination of the reviewer. That being said, we may earn a commission when a user completes an action using our links, which will however not affect the review but might affect the rankings. The latter are determined on the basis of customer satisfaction of previous sales and compensation received.

Reviews Guidelines

The reviews published on vpnMentor are written by experts that examine the products according to our strict reviewing standards. Such standards ensure that each review is based on the independent, professional and honest examination of the reviewer, and takes into account the technical capabilities and qualities of the product together with its commercial value for users. The rankings we publish may take into consideration the affiliate commissions we earn for purchases through links on our website.

What is Encryption and How Does It Work?

Encryption is used nowadays on even the simplest of apps. Since it’s so simple to hack your information online, encryption and other types of cryptography are the best tools available to protect your information.

Most applications and programs use some sort of encryption. The best VPNs use AES with 256 bit-keys, which is one of the reasons VPNs are the best way to secure your online activity.

Other popular apps, like WhatsApp and Gmail, also use some sort of encryption.

But, while we use cryptography in our daily lives, most of us don’t know how it works.

To help us understand how cryptography works, we’re going to look at a practical example.

The Problem with Open Channels

Imagine a standard online chat room where users can communicate with each other via text message. How would we then build a secure chat room with encrypted messages?

The first implementation is a simple TCP-based communications channel. Since there’s no security, every message users send is open to attack.

So, when Alice and Bob text each other, attackers can simply come between them and eavesdrop. This is known as a Man in the Middle attack. Hackers can also alter the messages and reroute them.

This is possible because the default communication channel passes the messages in plaintext. It does the same with all HTTP communication over open Wi-Fi networks. Clearly, we need a better system.

Symmetric encryption

Symmetric encryption uses an algorithm that converts the original plaintext message into a ciphertext encrypted message using an encryption key. The same key is used by the recipient to convert the ciphertext back to plaintext. Let’s apply this to our application.

When Alice wants to send Bob a message, she encrypts it with a symmetric key. When Bob receives it, he uses the same key to decrypt the message. Without it, attackers cannot access the encrypted communication between the two users, keeping it confidential.

Typically, a symmetric key is generated per session and is invalid for subsequent communication. We call it a session key.

Cryptography flow chart

However, there are shortcomings to this approach:

  1. Scalability: Our solution is not scalable. If 1,000 users want to communicate with each other, each of them would need 999 different keys to establish a secure channel.
  2. Key Distribution: We assumed that both the parties would have access to the symmetric key, but how do they get this key in the first place? If Alice generates a symmetric key (session key) and sends it over to Bob, the attacker could intercept it and decrypt any further communication.

So, what’s the next step?

Asymmetric encryption

Asymmetric encryption uses two keys – a private key and a public one. When the plaintext is encrypted with a public key, it can only be decrypted with the corresponding private one and vice-versa.

This helps us get around the problem of two symmetric keys. Asymmetric encryption is slower than symmetric encryption, so typically, they are both used in tandem. Let’s see how that is done:

Tandem use

Every user has a public-private key pair. The public key is available and known to everyone but the private one is confidential and protected by the owner.

When Alice wants to send a message to Bob, she first creates a symmetric session key. She then encrypts it with Bob’s public key. Since Bob owns the corresponding private key, only he can decrypt the message and get the session key.

From then on, that session key can be used to encrypt and decrypt messages between the two. This solves the problem of key distribution without compromising speed, since the slower asymmetric encryption is used only for the initial handshake.

We have also solved the problem of scalability since everyone needs just one public-private key pair to communicate with each other.

Now the system has improved significantly, but it is still not completely secured. We still have problems with:

  1. Authentication: We are using Bob’s public key as a starting point, but how did we get it? The public key we received first could have come either from Bob or from an impersonator, an attacker. So while we are communicating securely, it's with the wrong person.
  2. Data Integrity: The message could be altered during the transfer of data. We’ll want to make sure that the data has not been tampered with.

Certificates and Digital Signatures

Authentication requires a trust system. A trusted certificate authority (CA) ensures a public key belongs to a specific person. Each of the system users registers a digital certificate with the certificate authority (CA). This contains the owner’s identity information and a public key.

So, when Alice wants to communicate with Bob, she can check with the CA that the public key she received does indeed belong to Bob. This is also how HTTPS works on the Internet. One root certificate is linked to various child certificates with digital signatures (described below).

So, how do we know that the certificate received is from the root CA and not from the attacker? Typically, the root certificates from a trusted CA are hardcoded in the browser, which gives us a trusted baseline.

The problem of data integrity can be solved using digital signatures (not to be confused with digital certificates).

When Alice wants to send a message to Bob, she first creates a session key and encrypts it with Bob’s public one. Let’s call this data packet PART1. Then, she creates a message hash using one of the many available hashing algorithms (MD5/SHA256). A message hash is a one-way conversion from a variable length byte to a fixed-length one.

You can’t get the original message from the hash value, and it is statistically improbable for two messages to have the same hash value.

After creating the hash, Alice encrypts it with her private key. This is called a digital signature since it can be used to check that the message has come from Alice and has not been tampered with.

The digital signature and the original message is then encrypted with the session key. Let’s call this one PART2. Here is what we have now:



Alice sends both PART1 and PART2 to Bob. Since he owns the private key, only Bob can decrypt PART1 and access the SESSION_KEY.

Next, he uses this session key to decrypt PART2 and retrieve the message and digital signature. He then uses Alice’s public key to decrypt the digital signature and retrieve the message hash. Bob calculates the MESSAGE hash and compares it to the one from the earlier step.

If both the hashes match, it means that the data integrity has been preserved and there has been no tampering.

Digital signature

As you can see, we have now built a completely secure ecosystem.

Using certificates and digital signatures, we can create an encrypted authentication system that is quick, secure, confidential, and scalable.

Now that you know how encryption works, check out our favorite VPNs so you can see you can see it action.

About the Author

Harsh Maurya is a technology enthusiast who has contributed numerous open source and free tools to the public. In his spare time, he also likes to spread awareness about network security and is the author of the book How Not To Get Hacked.

Did you like this article? Rate it!
I hated it! I don't really like it It was ok Pretty good! Loved it!
out of 10 - Voted by users
Thank you for your feedback
Comment Comment must be from 5 to 2500 characters long.