Skip to content

Instantly share code, notes, and snippets.

@xeecos
Created March 17, 2022 00:49
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 xeecos/d14d1dc5b9224077c3cb4c17d406f8bd to your computer and use it in GitHub Desktop.
Save xeecos/d14d1dc5b9224077c3cb4c17d406f8bd to your computer and use it in GitHub Desktop.
bin2array
const fs = require("fs")
let buf = fs.readFileSync("file.bin");
let arr = [];
for(let i=0;i<buf.length;i++)
{
arr.push('0x'+buf[i].toString(16));
}
fs.writeFileSync("file.txt","["+arr.join(",")+"]")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment