What is Subresource Integrity (SRI)?
Subresource Integrity lets a browser check that a script or stylesheet loaded from another server has not been altered. You add an integrity attribute containing a hash of the file, such as sha384-... If the file the browser receives does not match, it refuses to use it.
This protects your page if a CDN or third-party host is hacked or serves a changed file. The value is the name of the algorithm, a hyphen and the hash written in Base64. This tool takes the exact contents of the file, builds that value and wraps it in a script or link tag with crossorigin set.
How to use the SRI Hash Generator
- Paste the exact contents of the file.
- Choose the algorithm, with SHA-384 as the default.
- Enter the file's URL so it appears in the tag.
- Copy the integrity value or the full tag.