Skip to content

Instantly share code, notes, and snippets.

@dehamzah
Last active October 27, 2024 00:48
Show Gist options
  • Save dehamzah/3db8fec14d19af50f7fcba2e74bdfb26 to your computer and use it in GitHub Desktop.
Save dehamzah/3db8fec14d19af50f7fcba2e74bdfb26 to your computer and use it in GitHub Desktop.
Generate secret key in NodeJS
require('crypto').randomBytes(48, function(err, buffer) { var token = buffer.toString('hex'); console.log(token); });
@RonyMiah
Copy link

node -e "console.log( require('crypto').randomBytes(24).toString('base64url'))"

Copy link

ghost commented Aug 6, 2024

You can omit console.log by using -p option: node -p "require('crypto').randomBytes(24).toString('base64url')"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment