Skip to content

Instantly share code, notes, and snippets.

@yhsgw
Created July 18, 2015 14:09
Show Gist options
  • Save yhsgw/4c2a3b4c3bc1027e1933 to your computer and use it in GitHub Desktop.
Save yhsgw/4c2a3b4c3bc1027e1933 to your computer and use it in GitHub Desktop.
16進ダンプした文字列を1byte毎の配列に変換する例
// "010aff"のような16進ダンプを、[1, 10, 255]のバイト配列に変換する/
var dumpToByteArray = function(str){
var byte_str = str.match(new RegExp(".{1,2}", "g"));
return byte_str.map(function(x){return "0x" + x; }).map(function(y){return parseInt(y)});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment