ojuso-map/bin/sri-hash

24 lines
558 B
Plaintext
Raw Normal View History

2017-06-16 16:06:22 +00:00
#!/bin/bash
usage="Usage: $(basename "$0") URL
Generate the subresource integrity hash (SRI) of URL.
--help display this help and exit"
seed=42
while getopts ':hs-help:' option; do
case "$option" in
h) echo "$usage"
exit
;;
:) printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
echo sha384-$(curl -s $1 | openssl dgst -sha384 -binary | openssl enc -base64 -A)