Skip to content

Instantly share code, notes, and snippets.

@FreddieOliveira
Last active April 11, 2022 21:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreddieOliveira/62b3d05f9086abe520dbd18a8485e4a2 to your computer and use it in GitHub Desktop.
Save FreddieOliveira/62b3d05f9086abe520dbd18a8485e4a2 to your computer and use it in GitHub Desktop.
Simple bash script to produce all Ceaser cypher variations (from rot1 to rot25)
#!/bin/sh
# original ideia from here: https://chris-lamb.co.uk/posts/decrypting-caesar-cipher-using-shell
# check number of arguments
if (( $# != 1 )); then
echo "Usage: $0 TEXT"
exit -1
fi
IN=$1
filling="[@*26]"
# see https://unix.stackexchange.com/questions/510838
# for further explanation
for i in $(seq 25); do
rot="[@*$i]"
tr $rot\A-Z$filling\a-z A-ZA-Za-za-z <<< "$i: $IN"
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment