#!/usr/bin/env bash

brt_encode() {
  local input="${1:-}"
  if [[ -z "$input" ]]; then
    brt_error "Usage: brt -encode <string|file>"
    exit 1
  fi
  if [[ -f "$input" ]]; then
    base64 < "$input"
  else
    printf '%s' "$input" | base64
  fi
}

brt_decode() {
  local input="${1:-}"
  if [[ -z "$input" ]]; then
    brt_error "Usage: brt -decode <string|file>"
    exit 1
  fi
  if [[ -f "$input" ]]; then
    base64 -d < "$input"
  else
    printf '%s' "$input" | base64 -d
  fi
}
