Created
May 20, 2018 22:23
-
-
Save robcalcroft/a1ae4b3a39c4e12bfbd1bbe2b88e539f to your computer and use it in GitHub Desktop.
Create a sha256 hash of a string in Node.js to use in a CSP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
function createSha256CspHash(content) { | |
return 'sha256-' + crypto.createHash('sha256').update(content).digest('base64'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment