SRI Hash Generator
Generate SHA-256, SHA-384 or SHA-512 Subresource Integrity attributes from local files. Copy script or stylesheet markup without uploading file contents.
Local files only, up to 20 MiB. The resource path is not fetched. Hash the exact file you will serve.
What is SRI Hash Generator
SRI Hash Generator creates a Subresource Integrity value from the exact bytes of a local file. Unlike the generic File Hash tool, it outputs the algorithm plus a Base64 digest and a script or stylesheet tag ready for review.
How to use SRI Hash Generator
- Select the actual JavaScript or CSS file you intend to publish, up to 20 MiB.
- Choose SHA-256, SHA-384 or SHA-512. Enter the resource URL or path used on your page and select stylesheet mode if needed.
- Generate and copy the markup. Recompute it whenever the served bytes change, then verify the deployed resource in your browser.
Features and limits
- Hashes raw file bytes locally with Web Crypto; secure context required.
- SHA-384 is the default; the URL field is used only to construct markup and is not fetched.
- Attribute characters are escaped in generated markup. The tool does not establish that a resource is trustworthy.
This tool processes your input in this browser and does not upload it for processing.
File contents: abc (no newline)
Algorithm: SHA-256
Integrity: sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=Frequently asked questions
Why does the browser block my resource?
The served bytes may differ from the selected file, or the resource may fail its cross-origin access checks. Compare the actual response and inspect the browser console.
Is crossorigin="anonymous" sufficient for a CDN?
No. Cross-origin SRI also requires an appropriate CORS response from the resource server. Adding the attribute alone cannot fix server configuration.
Does SRI replace HTTPS or check a file for malware?
No. SRI checks whether received content matches an expected digest. It does not judge the content or replace transport security. Choose the original resource through a trusted process.