From e7b24fc10b3221f464c6061855378a57d8c62d10 Mon Sep 17 00:00:00 2001 From: DrNuget Date: Thu, 13 Nov 2025 04:35:02 +0200 Subject: ROT encoder/decoder --- scripts/rot | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 scripts/rot 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; +} +' -- cgit v1.2.3