rice/password-gen.sh

25 lines
340 B
Bash
Raw Normal View History

2020-03-12 21:34:22 +00:00
#!/bin/sh
2022-05-02 02:38:12 +00:00
size=64
2020-03-12 21:34:22 +00:00
alnum() {
2022-05-02 02:38:12 +00:00
cat /dev/urandom | tr -dc [:alnum:] | fold -w $size | head -1
2020-03-12 21:34:22 +00:00
}
alnum_spec() {
2022-05-02 02:38:12 +00:00
cat /dev/urandom | tr -dc [:alnum:]'!@#$%^&*()-_=+' | fold -w $size | head -1
2020-03-12 21:34:22 +00:00
}
_help() {
echo 'Flags:
a - alphanumeric set
s - alphanumeric + special characters'
}
case $1 in
a) alnum;;
s) alnum_spec;;
*) _help;;
esac