diff options
| -rwxr-xr-x | scripts/rot | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/rot b/scripts/rot new file mode 100755 index 0000000..8deafb6 --- /dev/null +++ b/scripts/rot @@ -0,0 +1,41 @@ +#!/bin/sh +# Shell/AWK ROT cipher encoder/decoder +# Written by: DrNuget +# License: GNU GPL v2.0 + +while [[ $# -gt 0 ]]; do + case $1 in + -n) + ROT="$2" + shift + shift + ;; + *) + DATA="$DATA$1" + shift + ;; + esac +done + +echo "$DATA" | awk -vrot=$ROT -valph=$(echo -n {A..Z} , {a..z} | tr -d ' ') ' +BEGIN { + split(alph, alph_arr, ","); + for (j=1;j<=2;j++) { + cipher=substr(alph_arr[j], rot+1) substr(alph_arr[j], 1, rot); + for (i=0;i<26;i++) { + split(alph_arr[j], chars, ""); + split(cipher, cipher_chars, ""); + cipher_map[chars[i]]=cipher_chars[i]; + } + } +} + +{ + result=""; + split($0, chars, ""); + for (i=1;i<=length($0);i++) { + result=result cipher_map[chars[i]]; + } + print result; +} +' |
