

# rot13(){
#     ___x_cmd_cmds tr '[a-zA-Z]' '[n-za-mN-ZA-M]'
# }

____x_cmd_str_rot(){
    local rot=${1:-13}
    local letter='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789=-+'
    local before=${letter:0:$rot}
    local after=${letter:$rot}
    ___x_cmd_cmds tr $letter $after$before
}

___x_cmd_str_rot_encode(){
    local ROT=${1:?Provide rot number}
    shift
    if [ $# -eq 0 ]; then
        ____x_cmd_str_rot "$ROT"
    else
        printf "%s" "$1" | ____x_cmd_str_rot "$ROT"
    fi
}

___x_cmd_str_rot_decode(){
    local ROT=${1:?Provide rot number}
    shift
    if [ $# -eq 0 ]; then
        ____x_cmd_str_rot $(( 65 - ROT ))
    else
        printf "%s" "$1" | ____x_cmd_str_rot $(( 65 - ROT ))
    fi
}

___x_cmd_str_brb_encode(){
    local ROT=${1:?Provide rot number}
    shift
    if [ $# -eq 0 ]; then
        base64 | ___x_cmd_str_rot_encode "$ROT" | base64;
    else
        printf "%s" "$1" | base64 | ___x_cmd_str_rot_encode "$ROT" | base64;
    fi
}

___x_cmd_str_brb_decode(){
    local ROT=${1:?Provide rot number}
    shift
    if [ $# -eq 0 ]; then
        base64 --decode | ___x_cmd_str_rot_decode "$ROT" | base64 --decode
    else
        printf "%s" "$1" | base64 --decode | ___x_cmd_str_rot_decode "$ROT" | base64 --decode
    fi
}

