Created
June 5, 2020 21:09
-
-
Save mrk21/8f603ecad61a42eab53fce21e4a69c51 to your computer and use it in GitHub Desktop.
Binary to Binary String
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
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