I need to convert a png between binary and base64 due to communication with the server. However, when I use buffer there is inconsistency between directly reading the file in base64 versus reading the file in binary then converting to base64.
const fs = require('fs');
var data1 = Buffer.from(fs.readFileSync('test.png')).toString();
data1 = Buffer.from(data1).toString('base64');
var data2 = Buffer.from(fs.readFileSync('test.png')).toString('base64');
data1 == data2; //false
What could be causing the discrepancy?