Skip to content

Instantly share code, notes, and snippets.

@conceptblend
Created May 1, 2020 15:55
Show Gist options
  • Select an option

  • Save conceptblend/ed49ee9b85d06f87769d17cf8b017f08 to your computer and use it in GitHub Desktop.

Select an option

Save conceptblend/ed49ee9b85d06f87769d17cf8b017f08 to your computer and use it in GitHub Desktop.
Create a sub-resource integrity (SRI) hash for a script from the command line
#!/bin/bash
if [ "$1" ]; then
echo
echo "The subresource integrity hash for $1 is:"
hash=$( curl -s $1 | openssl dgst -sha384 -binary | openssl base64 -A );
echo
echo "<script src=\"$1\" integrity=\"sha384-$hash\" crossorigin=\"anonymous\"></script>"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment