CSP Nonce and Hash Generator
Generate a 128-bit nonce or SHA-256, SHA-384 and SHA-512 CSP sources from inline text or exact local file bytes.
Hash the Exact Inline Text for CSP
Use the contents inside the script or style tags. Pasted text uses UTF-8 with browser-normalized line breaks. File mode hashes every supplied byte.
CSP Nonce and Hash Generator: how to use it
- Choose Inline hash sources or Fresh nonce.
- For hashes, choose script-src or style-src and enter the content between the element tags. Select Exact file bytes to preserve the source file as read.
- Generate and copy or download the result. For a real nonce-based policy, generate a fresh nonce for every response at the server.
Limits and notes
Hashes up to 1,000,000 bytes with Web Crypto. Pasted text is UTF-8 with browser-normalized line endings. Each hash line is a source example to integrate into an existing policy.
How your privacy works →CSP Nonce and Hash Generator: common questions
Do I include the script or style tag?
Hash the inline contents between the start and end tags. Include the spaces and newlines the browser sees.
Why does my saved file hash differ from pasted text?
Files preserve every byte, including BOM and CRLF. Pasted text uses the browser's text field line breaks and UTF-8 encoding.
Can I use the same nonce across responses?
Generate a fresh unpredictable nonce for every response. Within a response, the header source and each intended inline element's nonce attribute should agree.