Trust in the result / 09SI · L00P.AI

Same content, different file hash

A hash compares bytes. Equivalence of parsed data needs an explicit rule for fields, types and normalization.

2026-11-19 · 1.0 · PL / EN

01 / What are you comparing?

An export has been saved again and its SHA-256 is different. Did the data change, or only its representation? The recipient needs two answers: whether they received exactly the same bytes and whether the parsed data meets an agreed equivalence rule. Each check serves its own purpose.

The article on restoring a backup compared file hashes with a reference. The article on HTML, Markdown and JSON parity read edition fields. Here we ran a separate trial: different representations of one JSON record, strict field types and normalization of one designated label. This is the rule for this example, rather than a universal definition of “same content”.

02 / Start with the data contract

Our fictional record contains exactly four fields. id and label are strings, count must parse as exactly Python's int type, and tags is a list of strings. Every field is required; extra fields are rejected. The reader code rejects repeated keys, but this trial does not compare different parsers' handling of duplicates.

{"id":"DOC-A","label":"kąt","count":7,"tags":["first","second"]}

Before comparison, we normalize only label to NFC. The identifier and tags elements are compared exactly, preserving list order. Polish diacritics are retained. The contract rejects count written as 7.0 or true; neither is an acceptable counter even if a looser value comparison could lose the type distinction.

03 / One record, different bytes

Different hashes: spacing and key order yield equal parsed data; the NFD label needs NFC. Changing 7 to 8 remains a difference. Four invalid inputs were rejected.
BYTES -> SHA-256 -> comparison with byte reference
   |
   +-> PARSE -> TYPES AND FIELDS -> NFC label only -> COMPARE

spacing / key order / escaped spelling: equal after parsing
NFD label: equal only after declared NFC normalization
count 7 -> 8: different under the contract too

In the trial of 19 November 2026, the compact representation occupies 65 bytes, the indented version with a final newline 96, the escaped representation 69, and the NFD-label version 66. Each has a different SHA-256. Indentation, reversed key order and an escape sequence for the letter ą did not change the values after parsing.

The NFD variant does contain a different character sequence: U+0061 and U+0328 replace U+0105. Ordinary comparison of the parsed dictionaries found a difference. Only the declared label normalization produced equality. Sorting keys when serializing again did not unify these two labels.

Changing 7 to 8, reversing the tag list, changing DOC-A to DOC-B and replacing “kąt” with “kat” remained differences under the contract. Four inputs were rejected: a floating-point counter, a Boolean counter, a missing field and an extra field. These controls prevent every convenient change from being treated as cosmetic.

04 / What the sources explain

RFC 8259 describes JSON syntax, whitespace, objects, arrays and character representations. It does not establish our four-field contract. The Python 3.11 json documentation explains parsing, types and serialization options. The data owner must decide which differences matter for acceptance.

The unicodedata documentation explains NFC and NFD; hashlib describes computing a digest from bytes. Equality after normalization does not replace keeping the original file. Record both outcomes: the hash comparison and the data comparison with the name and version of its rule.

05 / Acceptance card

Goal: same bytes / equivalent data under a contract
Trusted reference and original SHA-256:
Parser version and comparison-rule version:
Required fields, types, missing and extra fields:
Normalization: label only / NFC
ID and tags: exact; tag order preserved
Controls: formatting, NFD, 7->8, wrong type
Byte result / logical result / rejected inputs:

The trial passed 34 checks on 13 files of our own: nine variants valid under the schema and four rejected inputs. This is one small trial, rather than 34 independent experiments. We retained the expected-outcome protocol, inputs, code, results and manifest; files were read again and hashes compared without rerunning the original experiment.

06 / Limits and responsibility

The runtime was Python 3.11.11 with Unicode database 14.0.0. We did not test all JSON data, other programming languages, performance, resilience to untrusted input or production data. This is not an implementation of JSON canonicalization standard RFC 8785. Hash collisions, signatures and authentication were not tested. Comparing a hash with a trusted reference helps check bytes; the hash alone does not establish authorship or the truth of the data.

Codex produced the fictional data, code, PL/EN text and original static SVG with an ASCII equivalent. It performed the agent roles of editorial preparation, management and checking. There was no independent review by a second model or reader trial. Technical sources were checked on 19 November 2026; the current documentation revision does not change the recorded trial version.

A change to the schema, parser, normalization scope or meaning of ordering requires renewed acceptance. Before calling two exports equivalent, can your team identify the rule used to compare them?