Skip to content

Instantly share code, notes, and snippets.

@tomi
Last active March 14, 2024 03:28
Show Gist options
  • Save tomi/0675e58919af4554b198cee3f84405e5 to your computer and use it in GitHub Desktop.
Save tomi/0675e58919af4554b198cee3f84405e5 to your computer and use it in GitHub Desktop.
Saving and reading private key to env variables using base64

Encoding the private key as base64

  • Copy the private key to clipboard
  • Run command pbpaste | base64 | pbcopy
  • The private key is now base64 encoded in the clipboard. Paste it to env variable e.g. to heroku or to .env file

Decoding the private key from base64 in node.js

const private_key = new Buffer(process.env.PRIVATE_KEY, 'base64').toString('ascii');
@ammarorokushorking
Copy link

Private key find

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