Subresource Integrity (SRI) Hash Generator
Generate W3C Subresource Integrity hashes and secure HTML tags for CDN JavaScript and CSS files in your browser.
The remote server must support CORS (Access-Control-Allow-Origin: *), as standard CDNs like cdnjs, jsDelivr, unpkg, and Google Hosted Libraries do.
What is W3C Subresource Integrity (SRI)?
When websites include scripts or styles from public CDNs like <script src="https://cdn.../lib.js">, they introduce a supply chain attack vector. If the CDN account or DNS is compromised, attackers could inject malicious cryptocurrency miners or credential stealers into millions of visitor sessions.
Subresource Integrity (SRI) mitigates this risk by providing a cryptographic digest inside the integrity="..." attribute. The browser computes the digest of the incoming asset and refuses to execute the script if a single character has been modified.
Frequently Asked Questions
What happens if a CDN script updates without changing the SRI hash?
The browser will trigger an SRI mismatch error and block the script from executing. Always pin CDN URLs to exact, immutable version numbers (e.g. @5.3.0) rather than rolling tags like @latest.
Can I specify multiple hashes for redundancy?
Yes, the integrity attribute accepts space-separated hashes (e.g. integrity="sha384-... sha256-..."). The browser will validate using the strongest algorithm it supports.