#!/bin/sh

# 0-32767
# LENGTH=${1:-6}

if command -v awk >/dev/null; then
  awk 'BEGIN { srand(); print int(rand()*32768) }' /dev/null
elif command -v python >/dev/null; then
  python -c "import secrets; print(secrets.randbelow(32767))"
else
  printf '%s' $(($(dd if=/dev/urandom bs=2 count=1 2>/dev/null | cksum | cut -d' ' -f1) % 32767))
fi

# RANDOM=$(($(dd if=/dev/urandom bs=2 count=1 2>/dev/null | cksum | cut -d' ' -f1) % 32767))
