# What is Encryption and how does it work?

### Encryption is all around of us, but what are the different types of encryption, how do they work, and where are they used?

Encryption is a method of scrambling data in a way that can’t be read (called ciphertext). One feature of this *ciphertext* is that it needs to be able to be reversed (unlike hashing algorithms).

## What are the different types of Encryption Algorithms?

There are many different types of encryption algorithms that are used across the world. From how we access websites, to how E2EE apps’ messages are encrypted, even how we watch videos online, everything is encrypted.

These algorithms typically fall into one of two categories:

symmetricorasymmetric, which are differentiatied by how the encryption and decryption keys are implemented, as well as how many keys are required.

### Symmetric Encryption Algorithms

**Symmetric Encryption** algorithms are essentially where the same key that was used to encrypt the data is also used to decrypt the data. These sort of algorithms are used when encrypting hard drives, laptops, password managers etc. This is equivalent to a lock on a chest, where the one key is used to lock and unlock the chest (assuming there’s only one lock on the chest of course)

AES,DESandTriple DESare some commonsymmetric encryptionalgorithms.AES(Advanced Encryption Standard) was released in 1998 and supersedesDES(Data Encryption Standard) (first published in 1977) as the standard forsymmetric encryption.

Of these symmetric encryption algorithms, there are two types of traditional ciphers known as substitution ciphers and transposition ciphers.

**Substitution Ciphers**

These are ciphers that have a one-to-one mapping of characters to an encoded character. A common example of this is a *caesar cipher* or *ROT13*, where each letter is mapped to another letter in the alphabet. For *ROT13*, all letters are mapped to the letter 13 characters away. The *caesar cipher* follows the same concept, but instead of the “rotation” being 13, it’s any arbituary value *n* which is the *key*

Example: The ciphertext “Yhxrjnez Frphevgl Vasb vf gur orfg!” would be decoded to “Lukewarm Security Info is the best!” (ROT13).

**Transposition Ciphers**

These are ciphers where the text is reordered without changing the characters themselves. Common examples of these include the “Rail Fence Cipher”, “Skytale” (similar to the Rail Fence Cipher), and “Route Cipher”.

Example: The above example would be written in ciphertext as “SED ERTOE CC”, being decoded to “SECRETCODE” (Rail Fence Cipher).

### Asymmetric Encryption Algorithms

**Asymmetric Encryption** algorithms use different keys to encrypt and decrypt. The approach behind these is that one key is a *public* key (publicly known), and one is a *private* key (kept as a secret to just you). This type of encryption is used to encrypt messages to others, but also as a verification method for message receivers.

RSA(Rivest, Shamir, and Adleman - names after the three creators) is a commonly used asymmetric encryption algorithm found in many online tools such as HTTPS, E2EE Apps, SSH, and GitHub.

**RSA Encryption Algorithm**

The RSA Algorithm is a common public-key encryption algorithm that was created in 1977 and is still used today. With complex maths involved, it utilises the mathematics property where summing two numbers together is easy to do, but finding the two original numbers used to sum is much harder. For example, if the sum is 18, three possible values (or key pairs) would be

Imagine a post box. Anyone can put a letter in, (public) but only the person with a certain

privatekey can unlock the box and view the letter. The hole in the box is synonymous to a public key that everyone has access to. The box, however, can only be unlocked and the messages read by the holder of the key.

## TLDR;

Encryption algorithms are cryptographic algorithms that output a type of text known as *ciphertext*. This text needs to be unable to be understood (like hashing algorithms), but when passed through the same algorithm with the same (symmetric) or different (asymmetric) keys, it needs to be able to be understood again. There are two types of ways to encrypt data, these are *symmetric* algorithms which have one key to encrypt and decrypt the data, and *asymmetric* algorithms which have two keys; one to encrypt and one to decrypt.