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
Post a Comment