-
-
Save webuniverseio/3ca97204d74c0c03afb86e9ecfebc7ec to your computer and use it in GitHub Desktop.
Generates the right sha1 and sha256 for Content Security Policy aware scripts
This file contains 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
#!/usr/bin/env bash | |
echo '' | |
if [ "$1" = "" ]; then | |
echo 'csp sha1 and sha256 generatoor' | |
echo 'csp "code"' | |
echo 'csp /file-name' | |
else | |
if [ -f "$1" ]; then | |
CONTENT=$(cat $1) | |
else | |
CONTENT=$1 | |
fi | |
echo "sha1-$(echo -n "$CONTENT" | openssl dgst -sha1 -binary | base64)" | |
echo "sha256-$(echo -n "$CONTENT" | openssl dgst -sha256 -binary | base64)" | |
fi | |
echo '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment