Skip to content

Instantly share code, notes, and snippets.

@umegaya
Created March 6, 2018 18:55
Show Gist options
  • Save umegaya/f0b93ff53faf466dbee28a93491e24e2 to your computer and use it in GitHub Desktop.
Save umegaya/f0b93ff53faf466dbee28a93491e24e2 to your computer and use it in GitHub Desktop.
convert arbiter length of hexdump string "0x...." to byte array
var toBytes = (hexdump) => {
var buff = new Uint8Array(hexdump.length / 2 - 1);
var idx = 0;
hexdump.substring(2).replace(/\w{2}/g, (m) => {
buff[idx++] = parseInt(m, 16);
});
return buff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment