Loading .bin/passwd-chk +10 −2 Original line number Diff line number Diff line #!/usr/bin/env bash set -euo pipefail CHECK='✓' GREEN=`tput setaf 2` RED=`tput setaf 1` BOLD=`tput bold` RESET=`tput sgr0` read -sp "password: "; echo hash=$(printf "$REPLY"|sha1sum|cut -f1 -d\ |tr a-z A-Z) prefix=$(head -c5 <<<"$hash") Loading @@ -8,6 +14,8 @@ prefix=$(head -c5 <<<"$hash") IFS=$'\n\r:' curl -s https://api.pwnedpasswords.com/range/$prefix|while read suffix count; do [[ $prefix$suffix == $hash ]] || continue echo "In database $count times" echo "${RED}${BOLD}${count}${RESET}${RED}" \ "people have had their accounts broken into using the password" \ "\"${REPLY}\".${RESET}" exit 1 done && echo "Not in database" done && echo "${GREEN}Not in database ${CHECK}${RESET}" Loading
.bin/passwd-chk +10 −2 Original line number Diff line number Diff line #!/usr/bin/env bash set -euo pipefail CHECK='✓' GREEN=`tput setaf 2` RED=`tput setaf 1` BOLD=`tput bold` RESET=`tput sgr0` read -sp "password: "; echo hash=$(printf "$REPLY"|sha1sum|cut -f1 -d\ |tr a-z A-Z) prefix=$(head -c5 <<<"$hash") Loading @@ -8,6 +14,8 @@ prefix=$(head -c5 <<<"$hash") IFS=$'\n\r:' curl -s https://api.pwnedpasswords.com/range/$prefix|while read suffix count; do [[ $prefix$suffix == $hash ]] || continue echo "In database $count times" echo "${RED}${BOLD}${count}${RESET}${RED}" \ "people have had their accounts broken into using the password" \ "\"${REPLY}\".${RESET}" exit 1 done && echo "Not in database" done && echo "${GREEN}Not in database ${CHECK}${RESET}"