Skip to main content
L
Loopaloo
Buy Us a Coffee
All ToolsImage ProcessingAudio ProcessingVideo ProcessingDocument & TextPDF ToolsCSV & Data AnalysisConverters & EncodersWeb ToolsMath & ScienceGames
Guides & BlogAboutContact
Buy Us a Coffee
L
Loopaloo

Free online tools for developers, designers, and content creators. Your files are processed in your browser and are never uploaded - no accounts required. A few network utilities (like What's My IP and Currency Converter) call public APIs to do their job and say so on their pages.

support@loopaloo.com

Tool Categories

  • Image Tools
  • Audio Tools
  • Video Tools
  • Document & Text
  • PDF Tools
  • CSV & Data
  • Converters
  • Web Tools
  • Math & Science
  • Games

Company

  • About Us
  • Contact
  • Blog
  • FAQ

Legal

  • Privacy Policy
  • Terms of Service
  • Disclaimer

Support

Buy Us a Coffee

© 2026 Loopaloo. All rights reserved. Built with privacy in mind.

Privacy|Terms|Disclaimer
  1. Home
  2. Web Tools
  3. SRI Hash Generator
Add to favorites

SRI Hash Generator

Create the integrity attribute and a ready-to-paste script or link element for a CDN file, or check an existing attribute against the file.

More web toolsJump to full guide
Related readingContent Security Policy: Protecting Your Website from Injection Attacks10 min

Initializing in your browser…

You might also like

CSP Builder

Build a Content Security Policy from presets, see what browsers will really enforce, and copy it for nginx, Apache, Express or a meta tag.

Password Generator

Make random passwords in one click, with the strength in bits calculated from the settings and the time each would take to guess.

CSS Button Generator

Design a CSS button with hover, pressed, focus and disabled states, each checked against WCAG contrast, and copy the CSS and HTML.

SRI Hash Generator: a worked example

You host a small helper script on a CDN at a versioned address and want the page to refuse it if the file ever changes.

The file (104 bytes) and its address

// A tiny script to try the generator with.
export function greet(name) {
  return `Hello, ${name}!`;
}

https://cdn.example.com/greeting@1.0.0/greeting.js
What SRI Hash Generator produces

What the tool gives you

sha384-mw0H14J/8jPisTggh6syyaICXWC/P5nhYpb5uKtif/i4ixCVKjEAYer6udJf9qA9

<script src="https://cdn.example.com/greeting@1.0.0/greeting.js"
  integrity="sha384-mw0H14J/8jPisTggh6syyaICXWC/P5nhYpb5uKtif/i4ixCVKjEAYer6udJf9qA9"
  crossorigin="anonymous"></script>

With all three algorithms on:
sha256-I57EkQNbQzXGYc0O7rX1Biiw6LCnUNAxxX1MhJtlfyc=
sha384-mw0H14J/8jPisTggh6syyaICXWC/P5nhYpb5uKtif/i4ixCVKjEAYer6udJf9qA9
sha512-oLBDskXGffgHRDL+JqkuxB0N3SwWNX/9l6GvDdeUui7tkki4A3Jdnkf3Ek3wTO50NBpGd+moYqrDCllGl+0eqQ==

The sha384 digest of these 104 bytes is 48 bytes long. In hex that is 96 characters starting 9b0d07d7; SRI writes the same bytes as 64 characters of standard base64 starting mw0H14J, which is exactly what openssl dgst -sha384 -binary greeting.js | openssl base64 -A prints. The element keeps crossorigin="anonymous" because the CDN is another origin, and the address names version 1.0.0 so the hash stays valid until you choose to upgrade. If you paste all three values into one attribute, a browser checks only the sha512 one, the strongest present.

About the SRI Hash Generator

Create the integrity attribute that stops a browser from running a script or stylesheet that has been changed. Drop in the file, fetch it by address or paste its contents, and copy a ready-made script or link element with the hash, your real address and the crossorigin attribute already in place. You can also paste an existing attribute to check it against a file.

Key features

  • sha256, sha384 and sha512 in standard base64, alone or together
  • Files of any size, fetched addresses, or pasted text hashed live
  • Ready-to-paste script, module script, stylesheet and preload elements with your address
  • crossorigin always included, anonymous or use-credentials
  • Warnings for http addresses, credentialed requests and mismatched preloads
  • Checks an existing attribute against a file and marks the hash a browser uses
  • Explains unusable hashes: sha1 or md5, base64url, wrong digest length
  • Accepts the reserved ?option suffix that some attributes carry
  • Everything runs in the browser; files are never uploaded

How to use

  1. 1Drop the file in, choose it, paste its contents, or press Try a sample script.
  2. 2Type the address the page will load it from, so the element carries it.
  3. 3Keep sha384, or switch on sha256 and sha512 as well.
  4. 4Pick the element type and copy the element, or copy just the attribute.
  5. 5To check an attribute you already have, switch to Check an attribute, add the file and paste it in.

How Subresource Integrity works, and what this tool checks

What the attribute does. Subresource Integrity (SRI) lets a page say exactly which bytes it expects from a script or stylesheet hosted elsewhere, usually on a CDN. The browser downloads the file, hashes it, and refuses to use it if the hash is different. If the CDN is compromised, or the file is quietly replaced, the page breaks safely instead of running someone else's code. The value has a simple shape: the algorithm, a hyphen, and the raw digest in standard base64, as in sha384-mw0H14J/8jPisTggh6syya.... That is why it looks nothing like the hex string sha384sum prints, even though the digest is the same.

Getting the file in. Drop a file, choose one, or press Try a sample script. You can also paste the contents, which are hashed as UTF-8 as you type, or type the file's address and press Fetch. Fetching only works when the server lets other sites read the file (it sends an Access-Control-Allow-Origin header); many CDNs do, some do not. When the browser blocks the request, download the file and drop it in: the hash is identical. Whatever you do, the address you type goes into the generated element, so the result can be pasted straight into your page.

One hash or several. sha384 is the usual choice and the default. You can switch on sha256 and sha512 as well, and all chosen hashes go into one attribute. A browser only checks the strongest algorithm present, so adding a weaker hash beside a stronger one neither helps nor hurts. Several hashes of the same algorithm are useful in one situation: during a rolling deployment, one attribute can accept either the old or the new version of a file.

The element and its pitfalls. Choose a classic script, a module script, a stylesheet, or a preload link for a script or style. The crossorigin attribute is always included because integrity on a file from another origin needs a CORS request; without it the load fails with an error about CORS that never mentions integrity. The tool warns when the address is plain http (blocked as mixed content on an https page) and when you pick use-credentials, and reminds you that a preload must carry the same hash as the element that uses the file, and that the address must name a fixed version, never a moving tag such as @latest.

Checking an existing attribute. Switch to Check an attribute, add the file, and paste the attribute from your page. Each hash is listed with the one a browser actually checks marked, and the tool explains what is wrong with any that cannot work: base64url characters where standard base64 is required, a digest of the wrong length, or an algorithm such as sha1 or md5 that the specification does not allow. An attribute made only of those is ignored, and the browser then loads the file without checking it at all. Everything is computed in your browser and nothing is uploaded.

Examples

  • Pinning a library from a CDN

    Download lib.min.js from the exact versioned address, drop it in, type the address and copy the script element. If the CDN ever serves different bytes, the browser refuses to run them.

  • A stylesheet with a preload

    Pick Preload (style) and then Stylesheet for the same file. Both elements carry the same hash, which is what the browser needs to reuse the preloaded file.

  • Auditing an old attribute

    A legacy page carries integrity="sha1-...". The checker reports that sha1 is not an allowed algorithm, so the browser ignores the attribute and loads the script unchecked. Generate a sha384 value to replace it.

Tips & best practices

  • Hash the file from the exact address you will use; a minified and an unminified build have different hashes.
  • Paste text carefully: line endings and a final newline change the hash.
  • Add the integrity hash to your build output, so a new release cannot ship with a stale value.
  • Pair SRI with a Content-Security-Policy that lists your CDN, so a script without a hash cannot load either.

Frequently asked questions

Which algorithm should I use?

sha384 is the common choice and the one the specification's own examples use. sha256 and sha512 are equally valid. Listing several only matters for the strongest one, because that is the only one a browser checks.

Why does my script fail with a CORS error after adding integrity?

A browser only checks integrity on a file from another origin when it fetched the file with CORS. The crossorigin attribute asks for that, and the server has to answer with Access-Control-Allow-Origin. Keep crossorigin="anonymous" in the element and make sure the CDN sends the header.

Why can the tool not fetch my file?

The page can only read a file from another site if that site allows it with an Access-Control-Allow-Origin header, and an http address cannot be read from an https page at all. Download the file and drop it in instead; the hash is the same.

Is the base64 here the same as sha384sum output?

It is the same digest written differently. sha384sum prints hexadecimal; SRI needs the raw bytes in standard base64. You can reproduce the value with openssl dgst -sha384 -binary FILE | openssl base64 -A.

What happens with a sha1 or md5 integrity value?

Browsers ignore algorithms the specification does not list. If every hash in the attribute is unusable, the attribute counts as empty and the file loads without any check, which is worse than it looks. The checker flags this in red.

Do I need a new hash when the library updates?

Yes. The hash pins exact bytes, so any change to the file, even a single space, needs a new value. That is also why the address should name a fixed version rather than a tag like @latest.

Is my file uploaded anywhere?

No. Hashing uses the browser's built-in cryptography and the file never leaves your device. Fetching an address downloads it straight into your browser.

Related tools and how they differ

  • Hash Generator: Hashes typed text in hex or base64, with HMAC; use it for general hashing rather than an HTML integrity attribute.
  • Checksum Calculator: Checks a downloaded file against a published checksum, which is the same idea for files you keep rather than load.
  • CSP Builder: Builds a Content-Security-Policy header, the other half of controlling which scripts a page may run.

Further reading

  • Content Security Policy: Protecting Your Website from Injection Attacks10 min read

How this tool handles your data

File and pasted-code hashing happen entirely in your browser. URL mode fetches the file directly from the host you enter, so that host sees the request; the downloaded bytes are hashed locally.