Protego field desk

Free security tool

SRI Hash Generator

Create integrity attributes for scripts and stylesheets. Hash exact file bytes locally or fetch a public resource through Protego.

Quick answer

Generate a base64 Subresource Integrity value for JavaScript or CSS using SHA-256, SHA-384 or SHA-512. Pasted text and uploaded files are hashed locally with Web Crypto. Public URLs are fetched by Protego. Copy the integrity attribute and tag, then test that the browser accepts the exact deployed resource and its CORS headers.

Choose your content

UTF-8 encoding. Textareas can normalize line endings; upload a file to preserve exact bytes. Empty content can also be hashed.

Deploy and verify

Use a versioned URL for reviewed bytes, add the generated tag, then check your browser console and Network panel. Cross-origin SRI needs a suitable CORS response from the resource server.

Keep your Content Security Policy and XSS defenses in place. SRI checks file integrity; it cannot establish that the original code is trustworthy. Space-separated hashes are supported: the browser uses the strongest supported algorithm present.

Frequently asked questions

What does Subresource Integrity check?

SRI lets the browser compare a fetched script or stylesheet with a hash you supplied. A mismatch blocks that resource. It does not inspect whether the code itself is safe.

Which algorithms can I use?

SRI supports SHA-256, SHA-384 and SHA-512 with base64 digests. This tool defaults to SHA-384 and computes all three so you can choose the value required by your deployment.

Why does a cross-origin tag need crossorigin?

Cross-origin SRI requires a CORS-enabled response. Use crossorigin="anonymous" and configure the resource server to allow your site with Access-Control-Allow-Origin. Adding the attribute alone does not make a server allow CORS.

Why can my browser report an integrity mismatch?

A hash covers exact content bytes after HTTP content decoding. Minification, encoding, whitespace and line endings can change it. Paste mode encodes text as UTF-8; upload mode preserves original file bytes. Regenerate after any content change.

Can integrity contain multiple hashes?

Yes. Separate values with spaces. Browsers consider the strongest supported algorithm present and accept a matching digest from that algorithm. Adding a weaker digest does not provide a fallback for different content.

Should I use a versioned resource URL?

Pin a reviewed version and regenerate its hash when updating. A mutable URL can start serving different bytes and fail integrity checks. URL mode fetches at most 2 MB through Protego with shared server lookup limits. Local text and file hashing has no account quota.

References