Commit 012e6e4d authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Create a version controlled scripts dir ~/.bin

Includes some useful salvaged scripts
parent 95743681
Loading
Loading
Loading
Loading

.bin/passwd-chk

0 → 100755
+13 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
set -euo pipefail

read -sp "password: "; echo
hash=$(printf "$REPLY"|sha1sum|cut -f1 -d\ |tr a-z A-Z)
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"
	exit 1
done && echo "Not in database"

.bin/term-colours

0 → 100755
+38 −0
Original line number Diff line number Diff line
#!/bin/bash
set -eu

: ${MAX_WIDTH:=$(tput cols)}

fmt="%i:%s"
colours=(
	black red green yellow blue
	purple cyan white
)

let cell_width=${MAX_WIDTH}/8
if [ $cell_width -lt 5 ]; then
	fmt="%i"
	colours=()
elif [ $cell_width -lt 8 ]; then
	colours=(
		blk red grn ylw blu
		ppl cyn wte
	)
fi

for i in $(seq 0 7); do
	tput setab $i
	tput setaf $((!i))
	printf -v str "$fmt" $i ${colours[$i]-}
	case $((cell_width - ${#str})) in
		0) printf "$str" ;;
		1) printf "$str " ;;
		2) printf " $str " ;;
		*)
			let pad="($cell_width - ${#str} - 1) / 2"
			printf "%${pad}s${str/:/: }%${pad}s" " " " ";;
	esac
done

tput op
echo