Skip to content

Instantly share code, notes, and snippets.

@mrk21
Created June 5, 2020 21:09
Show Gist options
  • Save mrk21/8f603ecad61a42eab53fce21e4a69c51 to your computer and use it in GitHub Desktop.
Save mrk21/8f603ecad61a42eab53fce21e4a69c51 to your computer and use it in GitHub Desktop.
Binary to Binary String
const data = [ 102222, 4000032 ];
const buffer = new ArrayBuffer(4 * 2);
const dv = new DataView(buffer);
data.forEach((v, i) => dv.setInt32(4 * i, v, false));
let result = '';
for (let i = 0; i < 4 * 2; i++) {
result += String.fromCharCode(dv.getUint8(i));
}
console.log(btoa(result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment