LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
← Reverse engineer a binary packfile
BUILD → VERIFY → EXPLAIN · STEP 1 OF 6

Inspect header, magic bytes, and version

Validate the binary signature, endianness flag, and format version before reading further.

UNDERSTAND

Bring these concepts with you

BUILD

Your implementation

  1. Download starter.mjs, sample.bin, and checks.mjs into the same folder.
  2. Inspect the first 8 bytes of the buffer: verify the 4-byte magic signature 'PACK' (0x50, 0x41, 0x43, 0x4B).
  3. Read the 2-byte major/minor version (uint16) and 2-byte flags (uint16) in Little-Endian format. Reject buffers that are too small or have mismatched magic bytes.
function parseHeader(buffer) {
  // Validate buffer size, check magic bytes ('PACK'), and extract version.
}
Need a hint?
  • Use buffer.subarray(0, 4).toString('ascii') to verify the magic bytes.
  • Check buffer.length < 16 before attempting to read header fields to prevent out-of-bounds errors.

Saved on this device · 0 / 6000 · Do not include passwords or private data.

VERIFY

Acceptance checks

From the folder containing your downloaded files, run:

node checks.mjs ./starter.mjs 1 through 6 1

This runs checks up to this step. Earlier steps must work first. Mark each result only after checking your implementation; the website does not run or grade it.

Record your attempt to enable the checklist and reference comparison.

Compare with the reference

Attempt the step first, then compare decisions and behavior. There can be more than one correct implementation.

EXPLAIN

Your interviewer asks

Why do binary file formats place a fixed magic signature at byte offset zero rather than relying on file extensions?

Say your answer aloud, then record the trade-offs and evidence in your notes above.

LOCAL VOICE REHEARSAL

Rehearse your step walkthrough aloud

Target pacing: 02:00 · Stays in this browser only; never uploaded.

00:00/ 02:00
AlifBay Prep