summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-10-22 22:04:23 +0200
committerErich Eckner <git@eckner.net>2021-10-22 22:04:23 +0200
commitbefdd51df5f622a813aa69f8dd2a0ead7c51fa13 (patch)
treef77d91235a8043231176b9beab3a2df4bda1f013
downloadobfuscate-master.tar.xz
initial commitHEADmaster
-rwxr-xr-xobfuscate36
1 files changed, 36 insertions, 0 deletions
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