Let\'s say I have a hex data stream, which I want to divide into 3-bytes blocks which I need to read as an integer.
For example: given a hex string 01be638119704d4
01be638119704d4
you should convert three byte to four byte.
function three(var sample){ var buffer = new Buffer(sample, 'hex'); var buf = new Buffer(1); buf[0] = 0x0; return Buffer.concat([buf, buffer.slice(0, 3)]).readUInt32BE(); }
You can try this function.