Fix crash when enter characters on password generator

This commit is contained in:
q3aql 2022-06-29 20:00:41 +02:00
parent 3056dc35ad
commit d6ef9e7956
3 changed files with 130 additions and 82 deletions

View File

@ -109,10 +109,19 @@ function vault_key_decrypt() {
function generate_password() {
if [ -z "${1}" ] ; then
default_long_password=20
elif [ ${1} -lt 8 ] ; then
else
expr ${1} + 1 &> /dev/null
num_error=$?
if [ ${num_error} -ne 0 ] ; then
size_pass=20
else
size_pass="${1}"
fi
# Create password
if [ ${size_pass} -lt 8 ] ; then
default_long_password=10
else
default_long_password=${1}
default_long_password=${size_pass}
fi
count_char_password=1
current_password=""
@ -129,6 +138,7 @@ function generate_password() {
if [ "${2}" != "param" ] ; then
echo -n "# Press enter key to continue " ; read enter_continue
fi
fi
}
function generate_password_menu() {

View File

@ -120,10 +120,19 @@ function vault_key_decrypt() {
function generate_password() {
if [ -z "${1}" ] ; then
default_long_password=20
elif [ ${1} -lt 8 ] ; then
else
expr ${1} + 1 &> /dev/null
num_error=$?
if [ ${num_error} -ne 0 ] ; then
size_pass=20
else
size_pass="${1}"
fi
# Create password
if [ ${size_pass} -lt 8 ] ; then
default_long_password=10
else
default_long_password=${1}
default_long_password=${size_pass}
fi
count_char_password=1
current_password=""
@ -140,15 +149,25 @@ function generate_password() {
if [ "${2}" != "param" ] ; then
echo -n "# Press enter key to continue " ; read enter_continue
fi
fi
}
function gen_password_dl() {
if [ -z "${1}" ] ; then
default_long_password=20
elif [ ${1} -lt 8 ] ; then
else
expr ${1} + 1 &> /dev/null
num_error=$?
if [ ${num_error} -ne 0 ] ; then
size_pass=20
else
size_pass="${1}"
fi
# Create password
if [ ${size_pass} -lt 8 ] ; then
default_long_password=10
else
default_long_password=${1}
default_long_password=${size_pass}
fi
count_char_password=1
current_password=""
@ -158,6 +177,7 @@ function gen_password_dl() {
count_char_password=$(expr ${count_char_password} + 1)
done
echo "${current_password}"
fi
}
function generate_password_menu() {

View File

@ -155,10 +155,19 @@ function vault_key_decrypt() {
function generate_password() {
if [ -z "${1}" ] ; then
default_long_password=20
elif [ ${1} -lt 8 ] ; then
else
expr ${1} + 1 &> /dev/null
num_error=$?
if [ ${num_error} -ne 0 ] ; then
size_pass=20
else
size_pass="${1}"
fi
# Create password
if [ ${size_pass} -lt 8 ] ; then
default_long_password=10
else
default_long_password=${1}
default_long_password=${size_pass}
fi
count_char_password=1
current_password=""
@ -175,17 +184,25 @@ function generate_password() {
if [ "${2}" != "param" ] ; then
echo -n "# Press enter key to continue " ; read enter_continue
fi
fi
}
function generate_password_gui() {
if [ -z "${1}" ] ; then
default_long_password=20
elif [ ${1} -lt 8 ] ; then
default_long_password=10
elif [ ${1} -gt 30 ] ; then
default_long_password=30
else
default_long_password=${1}
expr ${1} + 1 &> /dev/null
num_error=$?
if [ ${num_error} -ne 0 ] ; then
size_pass=20
else
size_pass="${1}"
fi
# Create password
if [ ${size_pass} -lt 8 ] ; then
default_long_password=10
else
default_long_password=${size_pass}
fi
count_char_password=1
current_password=""
@ -199,6 +216,7 @@ function generate_password_gui() {
echo ${current_password} >> ${pwsh_vault_password_copy}
echo > /dev/null | pwsh-vaultm -p " PASSWORD: ${current_password} $(generate_spaces 65)"
echo > /dev/null | pwsh-vaultm -p " Password has been copied to ${pwsh_vault_password_copy} $(generate_spaces 20)"
fi
}
function generate_password_menu() {