Skip to main content
added link to follow-up question
Source Link
Edward
  • 67.2k
  • 4
  • 120
  • 284

A follow-up to this question is Chunking strings to binary block-based output


A follow-up to this question is Chunking strings to binary block-based output


Tweeted twitter.com/StackCodeReview/status/1235309226320416768
added tables to show data structures
Source Link
Edward
  • 67.2k
  • 4
  • 120
  • 284

Counted string format

$$ \begin{array}{l|c|l} \text{name} & \text{length in bytes} & \text{description} \\ \hline \text{count} & 1 & \text{count of bytes that follow, range 0-255} \\ \text{string} & 0..255 & \text{string may or may not have NUL terminator} \\ \end{array} $$

Block format

$$ \begin{array}{l|c|l} \text{name} & \text{length in bytes} & \text{description} \\ \hline \text{signature} & 4 & \text{fixed 0xfecaadbe} \\ \text{data} & 248 & \text{the data} \\ \text{checksum} & 4 & \text{checksum of block as 32-bit unsigned value} \\ & & \text{with same endian-ness as signature} \\ \hline \text{Block} & 256 & \text{total block size} \\ \end{array} $$

Counted string format

$$ \begin{array}{l|c|l} \text{name} & \text{length in bytes} & \text{description} \\ \hline \text{count} & 1 & \text{count of bytes that follow, range 0-255} \\ \text{string} & 0..255 & \text{string may or may not have NUL terminator} \\ \end{array} $$

Block format

$$ \begin{array}{l|c|l} \text{name} & \text{length in bytes} & \text{description} \\ \hline \text{signature} & 4 & \text{fixed 0xfecaadbe} \\ \text{data} & 248 & \text{the data} \\ \text{checksum} & 4 & \text{checksum of block as 32-bit unsigned value} \\ & & \text{with same endian-ness as signature} \\ \hline \text{Block} & 256 & \text{total block size} \\ \end{array} $$

added 9 characters in body
Source Link
Edward
  • 67.2k
  • 4
  • 120
  • 284

Here is a sample hex dump of the output with some annotations. See the "Processing" section for an explanation of this data structure.

Here is a sample of the output with some annotations. See the "Processing" section for an explanation of this data structure.

Here is a sample hex dump of the output with some annotations. See the "Processing" section for an explanation of this data structure.

added sample data for additional clarity
Source Link
Edward
  • 67.2k
  • 4
  • 120
  • 284
Loading
Source Link
Edward
  • 67.2k
  • 4
  • 120
  • 284
Loading