Skip to content

Instantly share code, notes, and snippets.

@waleedsamy
Created September 21, 2015 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waleedsamy/0ac7a3d6cb08a7383b80 to your computer and use it in GitHub Desktop.
Save waleedsamy/0ac7a3d6cb08a7383b80 to your computer and use it in GitHub Desktop.
Subresource Integrity - SRI
## http://www.w3.org/TR/SRI
## modern browser chrome 45+ or firefix 43+ will check hash of javascript or css resource
## aginst new attribute 'integrity' and if not matched browser will not load this resources
alg=sha256
resource=resource.css;
integrity=$(cat $resource | openssl dgst -$alg -binary | openssl enc -base64 -A)
printf '<link rel="stylesheet" href="resource.css" integrity="%s%s">\n' "$alg-$integrity"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment