iconBjarne Verschorre

../encryption.md

Some terms

Some terms you’d need to know before we start:

What is encryption?

Encryption is the process of converting plaintext into ciphertext. This means taking normal text like “Hello World” and turning into something that looks like complete gibberish. The more gibberish it looks like, the better. Unlike hashing, encryption is reversible, meaning you can turn the gibberish back into the original text and unlike encoding, encryption requires a key to decrypt the message.

Substitution Cipher

One of the most basic forms of encryption is the substitution cipher. As the name suggests this is where you substitute one letter for another. For example, you could replace every “A” with a “Z”, every “B” with a “Y”, and so on.

ROT13 Example
ROT13 Example

For example, lets use a rotation of 23 (also known as ROT23)

A = X, B = Y, C = Z, D = A, …

Plaintext: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD

Have a look at Caesar Cipher as an example of a substitution cipher.

Substitution just means replacing one thing with another. In this case, we’re replacing one letter with another. You could replace a letter with multiple letters, or even a symbol.

Symmetric Encryption

This type of encryption uses the same key to encrypt and decrypt the message (symetric means same). This doesn’t require a lot of computational power and is generally faster than asymmetric encryption.

The problem is that if the key is compromised, then the attacker can decrypt all the messages. You’d also need a secure way to share the key with the other party.

Diagram of Symetric Encryption
Diagram of Symetric Encryption

Some popular symmetric encryption algorithms are:

Asymmetric Encryption

Also known as public-key encryption, this type of encryption uses two keys: a public key and a private key. The public key is used to encrypt the message and the private key is used to decrypt the message.

This is difficult for some people to understand, try this: Imagine a locked mailbox, it has a lock needed to open it to put a letter in and a different lock to open it to take a letter out. The PUBLIC facing part of the mailbox is the lock that anyone can use to put a letter in, this is the public key (something that anyone can just have). The PRIVATE part of the mailbox is the lock that only the owner of the mailbox can use to take a letter out, this is the private key (something that must never be shared).

Diagram of Asymmetric Encryption
Diagram of Asymmetric Encryption

In the driagram above, Alice wants to send a message to Bob. Bob has a public key and a private key. Alice uses Bob’s public key to encrypt the message and sends it to Bob. Bob then uses his private key to decrypt the message.

⚠️Never Share Your Private Key

It is called a private key for a reason, this one should in no case be published anywhere or accessable to anyone. You are free to publish and spread your public key though.

Some popular asymmetric encryption algorithms are:

← Improve IT Skills My Servers Tmux Config →