m/market labResearch, with a record.
Source on GitHub ↗

digest.hpp

1#pragma once2#include <cstdint>3#include <string>4#include <string_view>56namespace itch {7inline constexpr uint64_t fnv1a_offset_basis = 14695981039346656037ULL;8/** Extend a non-cryptographic FNV-1a digest with exact bytes, including any newlines. */9uint64_t fnv1a_bytes(uint64_t hash, std::string_view bytes);10/** Extend the CSV data-row digest with a line and exactly one trailing newline.11 * This preserves the historical checkpoint/replay digest format; it excludes the CSV header.12 */13uint64_t hash_csv_line(uint64_t hash, std::string_view line);1415/** Return the lowercase 64-character SHA-256 digest of exact in-memory bytes. */16std::string sha256(const std::string& bytes);1718/** Byte length and SHA-256 identity of a complete file. */19struct Fingerprint {20    uint64_t size;21    std::string digest;22};2324/** Read and hash a complete file. Throws std::runtime_error on open/read failure. */25Fingerprint fingerprint(const std::string& path);26} // namespace itch