Works on Mac OS X

This commit is contained in:
Yann Esposito (Yogsototh) 2011-10-16 21:33:47 +02:00
parent d739b3d893
commit b5922d54d3

View file

@ -38,17 +38,27 @@ else
read password
stty $oldmodes
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="sha512sum" ;;
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');}"'