Caesar Cipher
The Caesar cipher replaces every letter with the one a fixed number of positions further down the alphabet, wrapping around from Z to A. The shift is the key.
plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Zcipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B CBreaking it
Section titled “Breaking it”There are only 25 possible keys, so trying all of them takes a moment. Even without that, letter frequencies give the shift away: the most common letter in German and English text is E, so the most common letter in the ciphertext most likely stands for E.
text="Wkh txlfn eurzq ira"for i in $(seq 1 25); do from=$(printf "%s" {A..Z} | cut -c$((i + 1))-26)$(printf "%s" {A..Z} | cut -c1-$i) echo "$i: $(echo "$text" | tr "A-Za-z" "$from${from,,}")"doneROT13 shifts by 13, half the alphabet, so encrypting twice returns the original text and the same command does both. It hides spoilers, not secrets.
echo "Hello World" | tr 'A-Za-z' 'N-ZA-Mn-za-m'# Uryyb Jbeyq