Created
September 21, 2015 07:59
-
-
Save waleedsamy/0ac7a3d6cb08a7383b80 to your computer and use it in GitHub Desktop.
Subresource Integrity - SRI
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
## 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