updated drote
with claud ai's help
This commit is contained in:
+52
-18
@@ -296,10 +296,10 @@ rotl() {
|
|||||||
|
|
||||||
rote() {
|
rote() {
|
||||||
input="${1//./}"
|
input="${1//./}"
|
||||||
rote36 "$input"
|
rote36rotl "$input"
|
||||||
}
|
}
|
||||||
|
|
||||||
rote36() {
|
rote36rotl() {
|
||||||
if [[ -n $1 ]] ; then
|
if [[ -n $1 ]] ; then
|
||||||
|
|
||||||
# datestamp as base 36
|
# datestamp as base 36
|
||||||
@@ -312,6 +312,7 @@ rote36() {
|
|||||||
datestamp=${year}${month}${day}_
|
datestamp=${year}${month}${day}_
|
||||||
datestamp=`echo "${datestamp}" | tr '[A-Z]' '[a-z]'`
|
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)
|
rotl=$(rotl $1 0)
|
||||||
emailaddress=$datestamp$rotl"@reduxmail.com"
|
emailaddress=$datestamp$rotl"@reduxmail.com"
|
||||||
echo $emailaddress
|
echo $emailaddress
|
||||||
@@ -319,28 +320,61 @@ rote36() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# claud ai
|
||||||
drote() {
|
drote() {
|
||||||
local email="$1"
|
local email="$1"
|
||||||
# Extract base36 date and encoded string
|
|
||||||
local base36date="${email%%_*}"
|
|
||||||
local rest="${email#*_}"
|
|
||||||
rest="${rest%@reduxmail.com}"
|
|
||||||
|
|
||||||
# Decode base36 date
|
# Strip @reduxmail.com
|
||||||
local year36="${base36date:0:1}"
|
local local_part="${email%@reduxmail.com}"
|
||||||
local month36="${base36date:1:1}"
|
|
||||||
local day36="${base36date:2:1}"
|
|
||||||
|
|
||||||
local year=$(echo "ibase=36; ${year36^^}" | bc)
|
# Split on _ → datestamp and encoded parts
|
||||||
local month=$(echo "ibase=36; ${month36^^}" | bc)
|
local ds="${local_part%%_*}"
|
||||||
local day=$(echo "ibase=36; ${day36^^}" | bc)
|
local encoded="${local_part#*_}"
|
||||||
|
|
||||||
# Decode the rest using rotl with shift 0 (reverse of rotl 0 is itself)
|
# --- Base36 char to decimal ---
|
||||||
# If you have a function to reverse the encoding, use it here.
|
_b36_to_dec() {
|
||||||
# For now, let's assume rotl 0 is a simple rot13 (as in your example)
|
local c="${1,,}" # lowercase
|
||||||
local decoded=$(echo "$rest" | tr 'a-z' 'n-za-m')
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|||||||
Reference in New Issue
Block a user