Subresource Integrity hash
Hash a script or stylesheet file into an integrity attribute value.
Loading the tool…
What it does, how to use it, and questions
What it does
Subresource Integrity puts a hash of a script or stylesheet in the integrity attribute so the browser rejects unexpected bytes.
Hash a local file to sha256-…, sha384-… or sha512-…. This page never fetches a CDN URL.
How to use it
- Choose the algorithm (sha384 is common).
- Open the file.
- Copy the integrity value into your HTML.
Things to watch for
- If the CDN file changes, the hash must change. Pin versions.
- Fetching a URL would break the privacy promise; paste or open a file you already have.
Questions
- Why not fetch the CDN URL?
- ToolDeck does not download your content. Save the file locally first.
- Which algorithm?
- sha384 is widely used. sha256 and sha512 are offered.
- crossorigin attribute?
- Anonymous CORS is often required for SRI on cross-origin scripts. That is configured in HTML, not here.
- Is the file uploaded?
- No. It is hashed in this page.