Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created March 22, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmota/d0d2aef5e04b0d52ecc725253cf59f6f to your computer and use it in GitHub Desktop.
Save miguelmota/d0d2aef5e04b0d52ecc725253cf59f6f to your computer and use it in GitHub Desktop.
Node.js file contents to base64 string
const fs = require('fs');
const data = fs.readFileSync('data.txt', 'binary');
const base64 = new Buffer(data, 'binary').toString('base64');
console.log(base64);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment