diff options
| author | DrNuget <drnuget@outlook.com> | 2025-11-13 04:35:02 +0200 |
|---|---|---|
| committer | DrNuget <drnuget@outlook.com> | 2025-11-13 04:35:02 +0200 |
| commit | e7b24fc10b3221f464c6061855378a57d8c62d10 (patch) | |
| tree | 2b5a91d54cf397f5f85388347432c798f94308d6 | |
| parent | 2dc4a36237cfc74886dabe07e209441ec206cc31 (diff) | |
| download | scripts-e7b24fc10b3221f464c6061855378a57d8c62d10.tar.gz | |
ROT encoder/decoder
| -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; +} +' |
