Skip to content

Instantly share code, notes, and snippets.

@aortbals
Last active April 20, 2017 17:56
Show Gist options
  • Save aortbals/ca8812e19d1093b37ff23c6da17112a7 to your computer and use it in GitHub Desktop.
Save aortbals/ca8812e19d1093b37ff23c6da17112a7 to your computer and use it in GitHub Desktop.
Generate a sha256-base64 string for a content security policy
#!/usr/bin/env node
const crypto = require('crypto');
if (!process.argv[2]) {
console.log('Usage: csp-sha <string>');
process.exit();
}
console.log(crypto.createHash('sha256').update(process.argv[2]).digest('base64'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment