Browse Source

Works on Mac OS X

master
parent
commit
b5922d54d3
  1. 26
      ypassword

26
ypassword

@ -38,17 +38,27 @@ else
read password
stty $oldmodes
case $hashalgo in
sha1) hashcmd="sha1sum" ;;
sha256) hashcmd="sha512sum" ;;
sha512) hashcmd="sha512sum" ;;
*) print -- "Unknown algorithm: $hashalgo" >&2
exit 1
esac
if [[ -x =shasum ]]; then
case $hashalgo in
sha1) hashcmd="shasum -a 1" ;;
sha256) hashcmd="shasum -a 256" ;;
sha512) hashcmd="shasum -a 512" ;;
*) print -- "Unknown algorithm: $hashalgo" >&2
exit 1
esac
else
case $hashalgo in
sha1) hashcmd="sha1sum" ;;
sha256) hashcmd="sha256sum" ;;
sha512) hashcmd="sha512sum" ;;
*) print -- "Unknown algorithm: $hashalgo" >&2
exit 1
esac
fi
if [[ $base64 = "b64" ]]; then
# make a hex2b64
hashcmd="$hashcmd | cut -f1 -d\\ | xxd -r -p | base64 --wrap=88"
hashcmd="$hashcmd | cut -f1 -d\\ | xxd -r -p | base64"
fi
cmd='echo -n "'$password$num$domainName'" | '$hashcmd' | awk "{print substr(\$1,1,'$longueur');}"'

Loading…
Cancel
Save