-
-
Save WebReflection/892939bcf8272bf4791f 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
How we use to create the ssh256 key for CSP? How we use in header?