July 2017
Intermediate to advanced
656 pages
16h 1m
English
We're going to write a simple program that strips all null bytes (bytes with a value of zero) from our file, and saves them in a new file called clean.dat.
First we'll require our dependencies:
const fs = require('fs') const path = require('path')
Now let's load our generated file into the process:
const cwd = process.cwd() const bytes = fs.readFileSync(path.join(cwd, 'file.dat'))
Next, we'll remove null bytes and save:
const clean = bytes.filter(n => n) fs.writeFileSync(path.join(cwd, ...