Created
May 1, 2020 15:55
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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