From befdd51df5f622a813aa69f8dd2a0ead7c51fa13 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 22 Oct 2021 22:04:23 +0200 Subject: initial commit --- obfuscate | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 obfuscate diff --git a/obfuscate b/obfuscate new file mode 100755 index 0000000..d7c9701 --- /dev/null +++ b/obfuscate @@ -0,0 +1,36 @@ +#!/bin/bash + +alphabets=( + $(printf '%s' {0..9}) + $(printf '%s' {0..9} {a..f}) + $(printf '%s' -.: {0..9} {a..z} {A..Z}) +) + +if [ -n "$1" ]; then + regex="$1" +else + regex='.*' +fi + +while IFS=$(printf '=\n') read -r l r; do + printf '%s=' "$l" + if printf '%s\n' "$l" \ + | grep -qx "${regex}"; then + for alphabet in "${alphabets[@]}"; do + printf '%s\n' "$r" \ + | grep -qx "[${alphabet}:]\+" \ + && break + done + for (( i=0; i<${#r}; i++ )); do + c="${r:$i:1}" + if [ -n "${alphabet%%*${c}*}" ]; then + printf '%s' "${c}" + else + printf '%s' "${alphabet:$(($RANDOM % ${#alphabet})):1}" + fi; + done + else + printf '%s' "$r" + fi + printf '\n' +done -- cgit v1.2.3-70-g09d2