Skip to content

Instantly share code, notes, and snippets.

@WebReflection
Last active November 11, 2020 00:08
Show Gist options
  • Save WebReflection/892939bcf8272bf4791f to your computer and use it in GitHub Desktop.
Save WebReflection/892939bcf8272bf4791f to your computer and use it in GitHub Desktop.
Generates the right sha1 and sha256 for Content Security Policy aware scripts
#!/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 ''
@sivaprabug
Copy link

How we use to create the ssh256 key for CSP? How we use in header?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment