From d00b8c3d92471476ec1ccce9c03f8c8520b6b6e8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 29 Mar 2025 13:39:10 -0300 Subject: Feat: sri-hash: support for more hash types, defaults to sha512 and added CSS support --- sri-hash | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/sri-hash b/sri-hash index 87ba453..bb9f5d9 100755 --- a/sri-hash +++ b/sri-hash @@ -9,6 +9,7 @@ # Parameters BASENAME="`basename $0`" URI="$1" +TYPE="${2:-sha512}" # Check if [ -z "$URI" ]; then @@ -19,12 +20,12 @@ fi # Get file if echo "$URI" | grep -q '^http'; then echo "downloading $URI and generating hash..." - HASH="`curl $URI | openssl dgst -sha384 -binary | openssl base64 -A`" + HASH="`curl $URI | openssl dgst -$TYPE -binary | openssl base64 -A`" echo "" else if [ -e "$URI" ]; then # See https://www.srihash.org/ - HASH="`openssl dgst -sha384 -binary $URI | openssl base64 -A`" + HASH="`openssl dgst -$TYPE -binary $URI | openssl base64 -A`" else echo "file not found: $URI" exit 1 @@ -32,6 +33,23 @@ else fi # Generate -cat < +if echo $URL | grep -q '.js$'; then + cat < EOF +else + cat < +EOF +fi -- cgit v1.2.3