# Console: Failed to find a valid digest in the 'integrity' attribute for resource … with computed SHA-256 integrity

**Code:** `Failed to find a valid digest in the 'integrity' attribute` · **Category:** Browser · **Seen on:** Chrome, Firefox, Safari, JavaScript

A `<script>` or `<link>` with an `integrity` hash was blocked because the downloaded file does not match that hash.

## Meaning

Subresource Integrity protects against modified CDN files. The browser prints the actual computed hash. A mismatch means the file changed (new version, different minification), the hash was copied for another URL, or a proxy altered the content. Regenerate the hash for the exact URL you serve.

## Common causes

- CDN file updated and `integrity` not updated
- Hash computed for a different URL, version or file
- Proxy/CDN injecting or minifying content
- Missing `crossorigin="anonymous"` on a cross-origin resource
- Line-ending or encoding changes in a self-hosted file

## Quick fix

1. Recompute the hash from the exact served file
2. Add `crossorigin="anonymous"` to cross-origin resources
3. Pin the CDN version in the URL

## Detailed fix by platform

### Linux

1. `curl -s https://cdn.example.com/lib.min.js | openssl dgst -sha384 -binary | openssl base64 -A` then use `sha384-<output>`
2. Or use srihash.org

### JavaScript

1. `<script src="https://cdn.example.com/lib@1.2.3/lib.min.js" integrity="sha384-..." crossorigin="anonymous"></script>`

## How to diagnose

1. **Hash** — Does the computed hash differ from the attribute?
2. **URL** — Exact same URL/version?
3. **CORS** — crossorigin set?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/browser/sri-integrity-mismatch)
