Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Introduction to Encryption and Cryptography. Join the course to learn more.

The encryption process

In this step you will learn about several of the main concepts in the encryption process, as well as some important terms.

As you have already seen, an encryption scheme transforms a plaintext into a ciphertext.

This transformation is conducted using an encryption algorithm. This is the set of instructions that you must follow to modify the plaintext so that it can be encrypted. For example, in a substitution cipher, the encryption algorithm determines which letter each letter in the plaintext will be substituted with. We will look at this in more detail in the next step.

A machine that takes a plaintext message and a key and outputs a ciphertext

The encryption algorithm takes two inputs — the plaintext and a key — and produces one output, the ciphertext. A key is a secret that determines the output of the encryption algorithm; different keys will produce different ciphertexts. This component allows you to restrict access to the message, as only those who know the key can decrypt the message.

Keys can be created using a key generation algorithm. This is the set of instructions used to create the key. For example, in a Caesar cipher, keys are generated by randomly choosing a number between 1 and 25. Keys can take many forms: in the Second World War, British spies used the first lines of poems as keys in their Vigenère ciphers, which often made them easy to guess. In modern-day encryption, keys are supposedly random strings of numbers and letters, although generating keys that are truly random and so cannot be guessed is still problematic. Often keys are pseudorandom, which means that they are not truly random, but appear to be random when analysed.

robot playing bingo, they have pulled out an A and there is board behind them with alphabet on it, 'C, F, I, P, R, S & V' have been circled on the board

To turn the ciphertext back into a plaintext, you must follow the decryption algorithm. This might simply be the reverse of the set of instructions that were followed to encrypt the plaintext. The decryption algorithm takes the ciphertext and the key as its inputs, and returns the plaintext.

A machine that takes a ciphertext and a key and outputs a plaintext message.png)

The algorithms should be designed so that the decryption algorithm always turns the encrypted form of a message back into the original message. If you make a mistake when following the encryption algorithm, the person decrypting the ciphertext will not be able to determine the plaintext.

If you have designed a strong encryption scheme, you should be able to let everyone know your key generation, encryption, and decryption algorithms without making it easier for your enemies to hack your system. As long as the key used to encrypt a message is kept secret, only the people who know the key should be able to decrypt the message correctly.

Next steps

In the next step you will learn the encryption, decryption, and key generation algorithms for a substitution cipher.

Questions

  • What is the key for an Enigma machine?
  • How can an encryption scheme be secure even if eavesdroppers know the key generation, encryption, and decryption algorithms?

Share your thoughts in the comments.

Share this article:

This article is from the free online course:

Introduction to Encryption and Cryptography

Raspberry Pi Foundation