Subresource Integrity (SRI) Hash Generator
Generates a Subresource Integrity hash and the full integrity attribute from pasted file contents, using Web Crypto.
Loading the tool…
How to use this tool
- Paste the exact contents of the .js or .css file you load from a CDN.
- Pick a digest algorithm if you need something other than the SHA-384 default.
- Select Generate hash and copy the integrity attribute, or the whole example tag, into your page.
- Regenerate the hash whenever the file changes - a mismatch makes the browser refuse to load it.
What sri hash generator does
Subresource Integrity lets a page pin the exact contents of a script or stylesheet it loads from a CDN, so a tampered file is refused rather than run. The attribute is fussy: a specific digest, base64 rather than hex, and an algorithm prefix the browser reads. Get any part wrong and the browser blocks a file that was perfectly fine, which is why hand-building the value goes badly.
Paste the exact contents of the file and this computes the digest with the browser Web Crypto API and writes out the whole integrity attribute, plus example script and link tags ready to paste. The hash must match the file byte for byte, so regenerate it whenever the file changes. It runs entirely in your browser - nothing you paste is sent anywhere, and this tool does not contact, scan or attack any website. Only review systems you own or are authorised to assess.