← All school projects

finished2025

Asset Engine: HexView, SafeReader, CryptFile

Three C and C++ exercises on binary files: a hex viewer, a reader that validates a custom format, and a byte-by-byte reversible cipher

C · C++ · Binary files · Checksum · XOR · Solo

GitHub ↗

Three small programs written during the GTech 3 "Asset Engine" week, to learn how to read, validate and transform files byte by byte.

Context

One exercise per day, from the provided briefs (D1 "HexView", D2 "SafeReader"): read any binary file, then define a small format with a header and a checksum and read it defensively, never trusting the file. Individual work, October 20 to 23, 2025.

What I did

HexView in two versions (C with malloc/fread, then C++ with std::vector and a class), SafeReader with its generation and corruption tools, then CryptFile. All three are then gathered in ExoComplet, one standalone file per exercise (built-in menu for SafeReader and CryptFile), with a README and a build script.

Links

The three exercises

DayProgramContent
D1HexViewDumps a file 16 bytes per line (offset, hex, ASCII), saves the dump to .txt, edits a byte at an offset, saves the edited file
D2SafeReaderGenerates, validates and corrupts .safe files
D3CryptFileEncrypts and decrypts a file with a text key, symmetry test

.safe format (D2)

HEADER (16 bytes)
  magic    : 4 bytes (0x45464153, "SAFE")
  version  : 4 bytes (1)
  dataSize : 4 bytes
  checksum : 4 bytes (XOR then 1-bit left rotation, byte by byte)
DATA (variable size)

The reader checks the signature, the version, the declared size against the real size, then the checksum. The corruption tool breaks one field at a time to check that each error is caught: magic, version, size, checksum, one data byte, or a truncated file.

Cipher (D3)

  • Encryption: 3-bit left rotation, then XOR with the key byte (((b << 3) | (b >> 5)) ^ key).
  • Decryption: XOR, then the reverse rotation.
  • The text key repeats over the whole file length.
  • The symmetry test encrypts, decrypts and compares the result with the original file.

Two versions of HexView

  • Classic C: fopen, fread, fwrite, malloc, free, typedef struct.
  • C++: HexView class, std::vector, std::ifstream / std::ofstream, replacing a block of bytes.

Stack

TechRole
C / C++17Language
g++ / Visual StudioBuild (compile_all.sh included)