29 lines
675 B
Bash
29 lines
675 B
Bash
#!/bin/bash
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
echo -e "\e[1;3;31mNeed ONE and only ONE digital parameter.\e[0m"
|
|
exit 1
|
|
fi
|
|
|
|
if ! [[ $1 -gt 0 && $1 -lt 80 ]] 2>/dev/null; then
|
|
echo -e "\e[1;3;31mNeed ONE DIGITAL parameter, which must be greater than 0 and lower than 80.\e[0m"
|
|
exit 2
|
|
fi
|
|
|
|
# total 80 bits password
|
|
pwgen_0=`pwgen -sync`
|
|
pwgen_1=`pwgen -sync`
|
|
pwgen_2=`pwgen -sync`
|
|
pwgen_3=`pwgen -sync`
|
|
pwgen_4=`pwgen -sync`
|
|
pwgen_5=`pwgen -sync`
|
|
pwgen_6=`pwgen -sync`
|
|
pwgen_7=`pwgen -sync`
|
|
pwgen_8=`pwgen -sync`
|
|
pwgen_9=`pwgen -sync`
|
|
|
|
pwgen_80=${pwgen_0}${pwgen_1}${pwgen_2}${pwgen_3}${pwgen_4}${pwgen_5}${pwgen_6}${pwgen_7}${pwgen_8}${pwgen_9}
|
|
echo ${pwgen_80:0:${1}}
|
|
|
|
|