Last active
April 26, 2021 16:16
-
-
Save oxr463/b52e27bf9ac537979c62183f313e0bd0 to your computer and use it in GitHub Desktop.
Encode/Decode binary as base64
This file contains hidden or 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
#!/usr/bin/env node | |
// SPDX-License-Identifier: MIT | |
// Decode binary from base64 | |
const fs = require("fs"); | |
const process = require("process"); | |
const util = require("util"); | |
process.argv.forEach(function (val, index, array) { | |
const txt = fs.readFileSync(val); | |
const bin = Buffer.from(txt,'base64').toString(); | |
console.log(util.inspect(bin, { maxArrayLength: null })); | |
}); |
This file contains hidden or 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
#!/usr/bin/env node | |
// SPDX-License-Identifier: MIT | |
// Encode binary as base64 | |
const fs = require("fs"); | |
const process = require("process"); | |
const util = require("util"); | |
process.argv.forEach(function (val, index, array) { | |
if(val.includes(".bin" || ".hex")) { | |
const bin = fs.readFileSync(val); | |
const txt = Buffer.from(bin).toString('base64'); | |
console.log(util.inspect(txt, { maxArrayLength: null })); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment