function PasswordQuest {
passdiaone=$(whiptail --nocancel --passwordbox "Please enter your password (Requires 8 chars, uper & lower case, special and numerical)" 11 91 --title "Config" 3>&1 1>&2 2>&3)
if [ -z $passdiaone ]; then PasswordQuest; fi
if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then
    PasswordCheck
else
    whiptail --ok-button Done --msgbox "   Password is invalid!" 10 30
    unset passdiaone
    PasswordQuest
fi
}

function PasswordCheck {
#Checking password
passdiatwo=$(whiptail --nocancel --passwordbox "                         Please re-enter your password" 11 82 --title "Config" 3>&1 1>&2 2>&3)
if [ -z $passdiatwo ]; then
    PasswordCheck
    else
    if [ $passdiaone != $passdiatwo ]; then
        whiptail --ok-button Done --msgbox " Password does not match!" 10 30
        PasswordQuest
    else
        echo "Pass okay" 
        password="$passdiaone"
        unset passdiaone passdiatwo
    fi
fi
}



function LegacyPasswordQuest {
echo "Enter password (Requires: 8 chars, 1 capital and 1 num)"
read -s passdiaone
if [ -z $passdiaone ]; then LegacyPasswordQuest; fi
if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then
    LegacyPasswordCheck
else
    echo "   Password is invalid!"
    unset passdiaone
    LegacyPasswordQuest
fi
}

function LegacyPasswordCheck {
#Checking password
echo "Please re-enter your password"
read -s passdiatwo
if [ -z $passdiatwo ]; then
    LegacyPasswordCheck
else
    if [ $passdiaone != $passdiatwo ]; then
        echo "Password does not match!"
        LegacyPasswordQuest
    else
        echo "Pass okay" 
        password="$passdiaone"
        unset passdiaone passdiatwo
    fi
fi
}


##Uncomment for Legacy
#LegacyPasswordQuest

##Uncomment for Whiptail
#PasswordQuest


#Retrun
echo "$password" 