Security

SRI Hash Generator

Generate a Subresource Integrity hash string from script or style content.

Last reviewed: April 30, 2026Free toolMethodology

SRI Hash Generator

These fields start with sample inputs. Keep them or replace them, then run the tool to show a fresh result.

Output

Calculating the sample result.

Why it matters

SRI helps browsers verify that fetched assets match the expected cryptographic digest, which is useful for pinned third-party assets and controlled deployments.

When to use

  • Preparing `integrity` attributes for scripts or styles
  • Verifying that a static asset hash matches expected content
  • Testing deployment workflows that pin asset content

Inputs & Outputs

Inputs

  • Asset content is the exact script or stylesheet text to hash.
  • Algorithm selects the SRI-compatible digest algorithm.

Outputs

  • Integrity string shows the final value ready for an HTML `integrity` attribute.
  • Raw Base64 digest is also displayed for debugging and verification.

SRI hash method

The tool hashes the input content with the chosen SHA algorithm, Base64-encodes the digest, and prefixes it with the algorithm label to create the final integrity string.

SRI format = algorithm + '-' + Base64(hash(content))

Worked example

1

Pinned asset review

A developer wants to generate the integrity value for an inline script before moving it to a hosted asset.

Inputs

  • Content: console.log('hello')
  • Algorithm: SHA-384

Steps

  • Hash the content
  • Encode the digest as Base64
  • Prefix the algorithm label

Result

  • The final integrity attribute value is ready to paste into markup.

Edge cases & caveats

  • Any content change, even a newline, will change the integrity value.
  • SRI is most useful when the asset URL is stable and the content is expected to be exact.

Frequently Asked Questions

Why use Base64 instead of hex here?

Because the SRI specification expects Base64-encoded digests with an algorithm prefix.

Can I hash a remote URL directly?

This tool hashes the content you provide locally. It does not fetch remote assets.

Keep going