Created
March 4, 2019 06:18
-
-
Save xuyazhong/1a50e2791823ba5cfc2eabd89adc1c23 to your computer and use it in GitHub Desktop.
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
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