sha256.md 721 B

Sha256 Utility Overview

Sha256.cpp provides a small helper to compute the SHA-256 digest of a file. The function is used during import to assign a stable, unique identifier for books; this id becomes the primary key in SQLite and the filename for cached covers.

Responsibilities

  • Stream a file from disk.
  • Feed the bytes through OpenSSL’s SHA-256 implementation.
  • Return the digest as a lowercase hexadecimal string.

Expected usage

std::string digest = sha256_file(path);

The caller is responsible for handling I/O errors (the helper throws if the file cannot be read). Since the digest is deterministic, re-importing the same file produces the same id, allowing updates to merge cleanly.