Subresource Integrity (SRI) Hash Generator

Subresource Integrity (SRI) Hash Generator

Local Processing

Generate W3C Subresource Integrity (SRI) string attributes (sha384-, sha256-, sha512-) for HTML script and link tags.

How It Works & Processing Standards

Generate W3C Subresource Integrity (SRI) string attributes (sha384-, sha256-, sha512-) for HTML script and link tags.

Tool processing runs in your browser. If you create a calculator or conversion share link, its values are included in the URL. See the privacy policy for account, analytics and advertising data.

Current Limits

  • Maximum input length: 2,000,000 characters

To let the browser detect a changed CDN script, put the file hash in the integrity attribute. Paste the file contents, choose an algorithm and get the "sha384-Base64" value.

One space or newline changes the hash, so the contents must match the deployed file exactly.

What You Can Do

sha256, sha384, sha512
The default is the recommended sha384.
Ready-to-use format
"algorithm-Base64", pasted straight into integrity.

How to Use Subresource Integrity (SRI) Hash Generator

  1. 1
    Paste file contentsPaste the script or stylesheet exactly.
  2. 2
    Choose an algorithmsha384, sha256 or sha512.
  3. 3
    Add to the tagUse integrity="…" crossorigin="anonymous".

Examples

sha384
Input: alert('hi');
Result: sha384-FANl2IiScBgbQg1ZiXDX2/KBIClVPK/2G9OPEEydFX4pOsLyf8a9qfpBudHpQY1u
sha256
Input: alert('hi');
Result: sha256-S3glexDivN1XnfRGec5uF4Y7TT2a/rcrADlE/zj4maA=

Common Use Cases

  • Adding integrity to CDN scripts to guard against supply-chain attacks
  • Making hash allow-list values for a CSP

Frequently Asked Questions (FAQ)

After adding integrity the script no longer loads.

Either the contents differ from the hash, or the file is cross-origin and lacks crossorigin="anonymous", so the browser blocks it.

Have feedback or ideas for this tool? Suggest & Inquire →