dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit ed7ed18a30fa8aeba0ea3ba4d3fd68bb41ae7a55
parent b5033c99b269cb926eda626010f1b77ac29c5ce2
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Thu, 12 Nov 2020 21:51:59 +0100

pwnedpass: improvements, POSIX sh compatibility

Former-commit-id: 9d7d4b008adc66b210c29562249bc1f87caec119
Diffstat:
Mscripts/pwnedpass | 19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/scripts/pwnedpass b/scripts/pwnedpass @@ -1,9 +1,12 @@ -#!/usr/bin/env bash -echo -n "pass> " -read -r -s pass_str -sha1=$(echo -n "$pass_str" | tr -d '\n' | shasum -a 1) -echo -echo "Hash prefix: ${sha1:0:5}" -echo "Hash suffix: ${sha1:5:35}" -result=$(curl https://api.pwnedpasswords.com/range/"${sha1:0:5}" 2>/dev/null | grep -i "${sha1:5:35}") +#!/bin/sh +printf "pass> " +stty -echo +read -r pass_str +stty echo +sha1=$(printf "%s" "$pass_str" | tr -d '\n' | shasum -a 1) +prefix=$(printf "%s" "$sha1" | cut -c-5) +suffix=$(printf "%s" "$sha1" | cut -c6-35) +printf "Hash prefix: %s\n" "$prefix" +printf "Hash suffix: %s\n" "$suffix" +result=$(curl -sL https://api.pwnedpasswords.com/range/"$prefix" 2>/dev/null | grep -i "$suffix") echo "Count: ${result#*:}"