Created
March 22, 2017 18:19
-
-
Save miguelmota/d0d2aef5e04b0d52ecc725253cf59f6f to your computer and use it in GitHub Desktop.
Node.js file contents to base64 string
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 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