diff options
-rwxr-xr-x | obfuscate | 36 |
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 |