| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | brt_pass() { |
| 4 | local length="${1:-20}" |
| 5 | if ! [[ "$length" =~ ^[0-9]+$ ]] || (( length < 8 )); then |
| 6 | length=20 |
| 7 | fi |
| 8 | if command -v openssl &>/dev/null; then |
| 9 | openssl rand -base64 48 | tr -dc 'A-Za-z0-9!@#$%^&*' | head -c "$length" |
| 10 | echo |
| 11 | else |
| 12 | head -c 256 /dev/urandom | tr -dc 'A-Za-z0-9!@#$%^&*' | head -c "$length" |
| 13 | echo |
| 14 | fi |
| 15 | } |
| 16 | |