Skip to content

Instantly share code, notes, and snippets.

@mz0
Created April 28, 2025 21:19
Show Gist options
  • Save mz0/6542fa58491c360feb666edafea23423 to your computer and use it in GitHub Desktop.
Save mz0/6542fa58491c360feb666edafea23423 to your computer and use it in GitHub Desktop.
Compute integrity_no="sha384-SgOJ...79m7" string for HTML resources
#!/bin/sh
if [ ! -n "$1" ]; then
echo "No file path argument found"
elif [ -f $1 ]; then
b64=$(sha384sum $1 | grep -o -E '^[a-f0-9]{96}' | xxd -r -p | base64)
echo "integrity=\"sha384-${b64}\""
else
echo "\"$1\" not found, or is not readable"
fi
# /usr/local/bin/integrity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment