1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00
programming-challenges/challenges/caesar-cipher/README.md

30 lines
1.2 KiB
Markdown
Raw Normal View History

2020-10-21 11:30:34 +02:00
# caesar-cipher
Created by [@Divlo](https://github.com/Divlo) on 21 October 2020.
2020-12-09 12:42:12 +01:00
## Instructions
2020-10-21 11:30:34 +02:00
In cryptography, a **Caesar cipher**, also known as **Caesar's cipher**, the **shift cipher**, **Caesar's code** or **Caesar shift**, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.
2020-12-09 12:42:12 +01:00
### Example of the alphabet with a rotation by 3
2020-10-21 11:30:34 +02:00
2020-12-09 12:42:12 +01:00
```txt
2020-10-21 11:30:34 +02:00
Original alphabet : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Alphabet rotated +3 : DEFGHIJKLMNOPQRSTUVWXYZABC
```
Complete the solution function. It should return the encrypted string.
The function has the following parameter(s):
- `string`: a string in cleartext (everything uppercase)
- `shift`: an integer, the alphabet rotation factor
2020-12-09 12:42:12 +01:00
## Source
2020-10-21 11:30:34 +02:00
- [Wikipedia - Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher)
2020-12-09 12:42:12 +01:00
## Examples
2020-10-21 11:30:34 +02:00
See the `input-output.json` file for examples of input/output.