Skip to content

Instantly share code, notes, and snippets.

@xuyazhong
Created March 4, 2019 06:18
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 xuyazhong/1a50e2791823ba5cfc2eabd89adc1c23 to your computer and use it in GitHub Desktop.
Save xuyazhong/1a50e2791823ba5cfc2eabd89adc1c23 to your computer and use it in GitHub Desktop.
HexString2Bytes(str) {
var pos = 0;
var len = str.length;
if (len % 2 != 0) {
return null;
}
len /= 2;
var arrBytes = new Array();
for (var i = 0; i < len; i++) {
var s = str.substr(pos, 2);
var v = parseInt(s, 16);
arrBytes.push(v);
pos += 2;
}
return arrBytes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment