From 2b1babdfe135cafc3a7ffa0265417c42204639d5 Mon Sep 17 00:00:00 2001 From: "committer@tuxwarrior" Date: Fri, 22 May 2026 05:51:59 -0500 Subject: [PATCH] updated drote with claud ai's help --- dots/bash/.bashrc | 70 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/dots/bash/.bashrc b/dots/bash/.bashrc index 7a8a2e8..f117754 100644 --- a/dots/bash/.bashrc +++ b/dots/bash/.bashrc @@ -296,10 +296,10 @@ rotl() { rote() { input="${1//./}" - rote36 "$input" + rote36rotl "$input" } -rote36() { +rote36rotl() { if [[ -n $1 ]] ; then # datestamp as base 36 @@ -312,6 +312,7 @@ rote36() { datestamp=${year}${month}${day}_ datestamp=`echo "${datestamp}" | tr '[A-Z]' '[a-z]'` + # the last part as: rotate the length (if string is 5 long rotate 5, if length is 6 rotate 6, etc) rotl=$(rotl $1 0) emailaddress=$datestamp$rotl"@reduxmail.com" echo $emailaddress @@ -319,28 +320,61 @@ rote36() { fi } +# claud ai drote() { local email="$1" - # Extract base36 date and encoded string - local base36date="${email%%_*}" - local rest="${email#*_}" - rest="${rest%@reduxmail.com}" - # Decode base36 date - local year36="${base36date:0:1}" - local month36="${base36date:1:1}" - local day36="${base36date:2:1}" + # Strip @reduxmail.com + local local_part="${email%@reduxmail.com}" - local year=$(echo "ibase=36; ${year36^^}" | bc) - local month=$(echo "ibase=36; ${month36^^}" | bc) - local day=$(echo "ibase=36; ${day36^^}" | bc) + # Split on _ → datestamp and encoded parts + local ds="${local_part%%_*}" + local encoded="${local_part#*_}" - # Decode the rest using rotl with shift 0 (reverse of rotl 0 is itself) - # If you have a function to reverse the encoding, use it here. - # For now, let's assume rotl 0 is a simple rot13 (as in your example) - local decoded=$(echo "$rest" | tr 'a-z' 'n-za-m') + # --- Base36 char to decimal --- + _b36_to_dec() { + local c="${1,,}" # lowercase + if [[ "$c" =~ [0-9] ]]; then + echo "$c" + else + # a=10, b=11, ... z=35 + # ASCII of a is 97; 97 - 87 = 10 ✓ + printf "%d" $(( $(printf '%d' "'$c") - 87 )) + fi + } - printf "%02d%02d%02d: %s\n" "$year" "$month" "$day" "$decoded" + # --- Decode datestamp (3 base36 chars → YYMMDD) --- + local yy mm dd yymmdd + yy=$(_b36_to_dec "${ds:0:1}") + mm=$(_b36_to_dec "${ds:1:1}") + dd=$(_b36_to_dec "${ds:2:1}") + yymmdd=$(printf "%02d%02d%02d" "$yy" "$mm" "$dd") + + # --- Reverse the rot cipher in pure bash --- + local size=${#encoded} + if (( size > 25 && size < 51 )); then + size=$(( size - 25 )) + fi + local shift=$(( size % 26 )) + + local decoded="" i c ascii base rotated + for (( i = 0; i < ${#encoded}; i++ )); do + c="${encoded:$i:1}" + ascii=$(printf '%d' "'$c") + if (( ascii >= 97 && ascii <= 122 )); then + # lowercase: base = 97 + rotated=$(( (ascii - 97 - shift + 26) % 26 + 97 )) + decoded+=$(printf "\\$(printf '%03o' "$rotated")") + elif (( ascii >= 65 && ascii <= 90 )); then + # uppercase: base = 65 + rotated=$(( (ascii - 65 - shift + 26) % 26 + 65 )) + decoded+=$(printf "\\$(printf '%03o' "$rotated")") + else + decoded+="$c" + fi + done + + echo "$yymmdd: $decoded" } # ---