Generate Subresource Integrity (SRI) hashes for JavaScript and CSS assets from pasted code or batch local files—with ready-to-paste HTML tags and built-in hash verification.
136 bytes
Algorithms Included in Tag
Ready-to-Paste HTML Integrity Tag
<!-- Drop local files or paste code to generate tags -->
Verify Existing Integrity Hash
W3C SRI SPECIFICATION REFERENCE
SRI Hash Algorithms & OpenSSL Equivalents.
Prefix
Digest Bits
Base64 Length
OpenSSL CLI Equivalent
sha256-
256 bits
44 chars
openssl dgst -sha256 -binary file.js | openssl base64 -A
sha384- (Recommended)
384 bits
64 chars
openssl dgst -sha384 -binary file.js | openssl base64 -A
sha512-
512 bits
88 chars
openssl dgst -sha512 -binary file.js | openssl base64 -A
1. Protect Against Compromised CDNs
Loading third-party scripts from public CDNs improves caching, but exposes your users to supply-chain attacks if a CDN account is hijacked. Pairing integrity="sha384-..." with crossorigin="anonymous" ensures browsers refuse to execute tampered payloads.
2. Always Pin Exact Asset Versions
Never attach an SRI hash to a floating URL like /lib@latest/index.js. As soon as the maintainer publishes a patch, the file bytes change and browsers will block your script. Always pin an exact immutable version URL (e.g., @2.0.4).
Every hash is computed natively inside your browser with crypto.subtle.digest—zero uploads, zero server logging, and instant batch support for local build outputs.
Frequently Asked Questions
What is a Subresource Integrity (SRI) hash?
Subresource Integrity (SRI) is a W3C browser security feature that lets you include a cryptographic hash (sha256, sha384, or sha512) inside <script> and <link> tags. Before executing a CDN script or applying a stylesheet, the browser hashes the fetched file and blocks it if a single byte was altered.
Which SRI hash algorithm should I use: SHA-256, SHA-384, or SHA-512?
SHA-384 is the W3C and industry standard default for SRI tags because it offers stronger collision resistance than SHA-256 while remaining compact in HTML. You can also include multiple space-separated hashes (e.g., sha384-... sha512-...) and browsers will validate against the strongest algorithm they support.
Why is crossorigin="anonymous" required with the integrity attribute?
When fetching a script or stylesheet from a different origin (such as jsDelivr, cdnjs, or unpkg), browsers require crossorigin="anonymous" so the server returns an Access-Control-Allow-Origin CORS header. Without it, the browser refuses to read the response body for integrity verification and blocks the resource.
How do I generate an SRI hash from the command line with OpenSSL?
Run: openssl dgst -sha384 -binary filename.js | openssl base64 -A — then prepend "sha384-" to the output. This browser tool performs the exact same SHA-256, SHA-384, and SHA-512 digest computation natively via the Web Crypto API.
Are my local JavaScript or CSS files uploaded to a server?
No. All cryptographic hashing uses your browser’s built-in window.crypto.subtle.digest() API in local RAM. Your files and code never leave your machine.