SRI Hash Generator.
Generate Subresource Integrity hashes and ready-to-paste script or link tags for CDN files.
Runs in your browserAbout SRI Hash Generator
The SRI Hash Generator computes the integrity value that lets browsers refuse a CDN file if its contents change. Upload the JavaScript or CSS file, or paste its exact contents, and the tool returns a value such as sha384-… together with a complete script or link tag that includes integrity and crossorigin="anonymous". If the file on the CDN is ever modified, whether by a compromise or by a silent update to an unpinned version, the browser blocks it instead of running it. SHA-384 is the default because it is what most CDNs and the SRI specification examples use; you can also produce SHA-256, SHA-512 or all three at once, in which case browsers use the strongest hash they support. For example, pasting console.log('Hello, SRI'); followed by a newline and the URL https://cdn.example.com/hello.js gives a ready script tag. The most frequent mistake is hashing text that differs from what the server sends: a missing final newline, Windows line endings or a minified versus unminified build all change the hash, so uploading the downloaded file is the safest option. Another is forgetting crossorigin, without which cross-origin integrity checks fail, and the CDN must send CORS headers. Always pin an exact version in the URL. Hashing uses WebCrypto in your browser, so the file is never uploaded.
How to Use
- Upload the exact file served by the CDN, or paste its contents.
- Pick the hash algorithm and enter the resource URL.
- Copy the integrity value or the full script/link tag into your HTML.
Frequently Asked Questions
Which algorithm should I use?
sha384 is the common choice. sha256 and sha512 are also valid; with several values in one attribute, browsers check the strongest one they support.
Why does the browser block my file even though I generated the hash?
The bytes differ from what you hashed (line endings, a trailing newline, a different build) or the CDN does not send CORS headers. Download the exact file and upload it here.
Do I need crossorigin="anonymous"?
Yes for files on another origin. Without a CORS request the browser cannot read the response to check its integrity, and the resource fails to load.
Is my file uploaded?
No. The hash is computed in your browser with WebCrypto and the page makes no network requests.
Related Tools
Generate MD5, SHA-256, SHA-512, and other hashes.
Check a Content-Security-Policy for XSS bypasses, or build one from a preset with ready-to-paste server snippets.
Encode and decode Base64 strings.
Decode PEM or DER certificates to see subject, issuer, validity, SANs, key and extensions.
Verify or compute HMAC signatures for GitHub, Stripe, Slack, Shopify and custom webhooks.
Hash and verify passwords with bcrypt or Argon2.