Skip to content

Instantly share code, notes, and snippets.

@Jcpetrucci
Last active August 14, 2019 08:54
Show Gist options
  • Save Jcpetrucci/ebd764f2be9b78ea3ee1 to your computer and use it in GitHub Desktop.
Save Jcpetrucci/ebd764f2be9b78ea3ee1 to your computer and use it in GitHub Desktop.
Tries all variations of Rot# (i.e. Rot13...Rot14...RotN)
#!/bin/bash
charset=abcdefghijklmnopqrstuvwxyz # Tweak $charset as needed for your alphabet
input=${1,,} #strtolower; greatly simplifies conversion
for char in $(seq 1 ${#charset}); do # Count characters in charset, and for each...
temp=${charset#?} # Strip the first character, save rest to $temp
charset=${temp}${charset%"$temp"} # Move the first character of charset behind the rest (abcde becomes bcdea)
echo $input | tr a-z $charset
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment