bytearray - Packing binary data in JavaScript -


if have unpacked binary data

1700885369 # translates 'easy' 

how can byte array (most preferably without importing anything)? python's struct.struct(format).pack:

>>> import struct >>> s = struct.struct('>1i') # big-endian, two-byte, unsigned int >>> s.pack(1700885369) b'easy' # bytearray([101, 97, 115, 121]) 

you can byte @ time value , put in array:

var value = 1700885369;  var arr = [];  while (value > 0) {    arr.unshift(value % 256);    value = math.floor(value / 256);  }    // display value in stackoverflow snippet  document.write(arr);


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -