demo · v141

Script Integrity Checker

Paste a <script> tag, parse the integrity attribute, and understand what algorithm you're using. Generate a real SHA-384 hash via the Web Crypto API, and explore how Ed25519 signature-based integrity differs from static hash-based SRI.

probing SubtleCrypto and signature-based integrity support…
Paste a <script> tag and press "Parse & analyse".

Paste script source text to compute the base64-encoded SHA-384 digest — the value you'd put after sha384- in an integrity attribute.

Enter script content and press "Compute SHA-384".

With Ed25519, the CDN signs each response. The browser verifies using the public key embedded in the integrity attribute. Any content signed by that private key passes — no hash update needed for new builds.

<!-- Ed25519 signature-based integrity -->
<script src="https://cdn.example/app.js"
        integrity="ed25519-[base64url-encoded-public-key]"
        crossorigin="anonymous"></script>

<!-- Server adds header on each response: -->
Signature: sig=:base64encodedSig:;keyid="app-key-v1";tag="sri"

<!-- Browser verifies: signature over response body matches public key.
     ANY content signed by the private key passes — including new builds. -->
Press "Simulate verification" to generate a real Ed25519 key pair and sign + verify a payload.

Hash-based vs signature-based: the trade-off

sha384

Hash-based SRI

  • Integrity value is a digest of exact content
  • Any content change → different hash → browser blocks
  • You must update every <script> tag on new builds
  • Works offline — no server-side signing required
  • Protects against CDN serving wrong version
  • Does not protect against origin compromise (attacker resigns)
ed25519

Signature-based SRI

  • Integrity value is the publisher's public key
  • Any content signed by the private key passes
  • No HTML changes needed on new builds — only re-sign
  • Requires CDN/server-side signing infrastructure
  • Key rotation: update public key in HTML once, rotate private key on server
  • Protects supply chain: CDN can't forge signatures without the private key

Scenario matrix

Scenario Hash SRI outcome Signature SRI outcome
Legitimate new build, same HTML BLOCK — hash mismatch PASS — signed by same key
CDN serves stale cached file BLOCK — hash mismatch BLOCK — old signature invalid for new response
Transit tampering (MITM) BLOCK — hash mismatch BLOCK — forged signature won't verify
CDN account compromised, attacker injects script PASS (if attacker serves original file) BLOCK — attacker cannot sign without private key
Private key rotated, HTML not yet updated PASS (hash still matches) BLOCK — old public key won't verify new signatures

see also