securepass.sh 438 Bytes
Newer Older
1 2 3 4 5
#!/bin/sh

## bcrypt passwd generator ##
#############################
CMD=$(which htpasswd 2>/dev/null)
6
OPTS="-nBC 12"
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

read -p "Username: " USERNAME

check_config() {
    if [ -z $CMD ]; then
        printf "Exiting: htpasswd is missing.\n"
        exit 1
    fi

    if [ -z "$USERNAME" ]; then
            usage
    fi
}

check_config $USERNAME
printf "Generating Bcrypt hash for username: $USERNAME\n\n"
$CMD $OPTS $USERNAME
exit $?