Shiklo Tools
PDF40
Image20
Calculators & Converters25
Text & Writing13
Developer26
Video14
Audio14
Document14
Data & Spreadsheet12
Web & SEO9
OCR & Scanning5
Archive & File12
Security & Privacy23
Health & Medical29
QR & Barcode5

SRI Hash Generator

Create Subresource Integrity hashes (sha384 and more) for scripts and stylesheets, with the ready script or link tag to paste.

When a page loads a script or stylesheet from a CDN or another server, it trusts that file completely: if the server is hacked or the file is swapped, the attacker's code runs on your site with full access to your visitors' data. Subresource Integrity (SRI) prevents this. You add an integrity attribute containing a hash of the file you expect, and the browser refuses to use any file that doesn't match.

This tool makes that hash. Choose the file, paste its exact content, or give its public address (most CDNs allow the browser to read their files), pick SHA-384 or another algorithm, and copy the integrity value or the complete script or link tag with the crossorigin attribute already set. Hashing uses the browser's Web Crypto API, so your files stay on your device.

How to use SRI Hash Generator

  1. Choose File, URL or Pasted code.
  2. Add the file, fetch the address, or paste the exact code.
  3. Choose the hash algorithm (SHA-384 is the usual choice).
  4. Copy the integrity value or the ready HTML tag.

Features

  • SHA-256, SHA-384 and SHA-512 integrity values.
  • From a file, a public URL or pasted code.
  • Ready script or stylesheet link tag with the crossorigin attribute.
  • Files up to 50 MB.
  • Web Crypto API in your browser.

How SRI works

The integrity attribute holds the algorithm and the Base64 hash of the file, such as sha384-oqVuAfXR…. When the browser downloads the file, it hashes it and compares. If the hashes differ — because the file was changed, corrupted or replaced — the browser blocks it and reports an error in the console. Cross-origin files also need crossorigin="anonymous" so the browser is allowed to read them for checking; the generated tag includes it.

PartExample
Algorithmsha384
Hash of the file, Base64H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO
Required for other originscrossorigin=anonymous

Which algorithm?

SHA-384 is the most common choice and what most CDNs publish. SHA-256 and SHA-512 are also supported by all browsers. You can list several values separated by spaces and the browser uses the strongest one it knows. All three are far beyond any practical attack; what matters is hashing exactly the file the browser will download.

When the hash must change

Any change to the file — a new version, a different minified build, even an added line break — changes the hash. Always link to a fixed version of a library (lib@1.2.3, not lib@latest), and update the integrity value when you update the version. Files that a server changes per request or per browser, such as some font or analytics loaders, can't be protected with SRI.

Reading files from other servers

The URL option downloads the file in your browser. That works when the server allows cross-origin reading, which jsDelivr, cdnjs, unpkg and most CDNs do — the same permission the browser needs to check SRI later. If a server doesn't allow it, download the file and choose it here instead. Your files and code are never uploaded; only the address you enter is fetched, directly from your browser.

Related tools

Combine SRI with a Content-Security-Policy that limits where scripts may load from — the CSP Generator builds one — and check your site's response headers with the Security Headers Checker. To hash any file with many algorithms, use the Hash Generator.

Frequently asked questions

Do I need SRI for files on my own domain?

It is mainly for files from CDNs and other servers; files you serve yourself are already protected by your own server.

Can I list several hashes?

Yes. Separate them with spaces; the browser uses the strongest algorithm it supports.

How do I generate an SRI hash?

Choose the file or URL, pick SHA-384 and copy the integrity value or the HTML tag.

Which hash should I use for SRI?

SHA-384 is the common choice; SHA-256 and SHA-512 also work.

Why is crossorigin needed?

Browsers only check the integrity of files from other origins when they are fetched with CORS.

Why does my integrity check fail?

The file changed or isn't exactly the same build. Hash the exact file the page loads.

Can I hash a file on a CDN?

Yes, if the CDN allows cross-origin reading, which most do.

Is my code uploaded?

No. Hashing happens in your browser.

Does SRI work for CSS?

Yes. The tool creates a link tag for stylesheets.

Related tools