Article

How to verify a bulk data transfer is complete and unchanged with checksums

How to confirm a bulk data delivery arrived complete and unchanged, with a sample manifest, sha256sum, a Python pre-load check and S3's own checksums.

9 min read

To verify that a bulk data transfer arrived complete and unchanged, compare what landed with a manifest written before the files left: every file name, its size in bytes, its row count and its SHA-256 checksum. A missing file, a short row count or a hash that differs means the transfer failed, and the load should stop until the sender delivers that file again.

This post sets out what each check catches, a sample manifest, commands for the shell, Python and Amazon S3, a worked example and a pre-load checklist. Sources are NIST, GNU coreutils, Python, the Amazon S3 user guide, the AWS CLI reference and two RFCs, all read between 15 and 18 November 2026.

How do you verify a bulk data transfer is complete and unchanged with a checksum?

You verify a bulk data transfer by hashing each file after it lands and comparing the result with the hash the sender computed before it left. Matching SHA-256 values show the bytes are unchanged. Completeness needs two more tests: every file in the manifest is present, and each file holds the row count the manifest states.

Each test answers a different question. A checksum says nothing about a file that never arrived, and a file count says nothing about a file cut off halfway. A row count taken from the source catches an export that was already short when it was hashed.

CheckWhat it showsWhat it misses
File list against the manifestEvery expected file arrived and nothing unlisted came with itA file that arrived cut short or altered
Size in bytesThe file has the length the sender wroteA change that keeps the length the same
SHA-256 checksumThe bytes match the sender's copy exactlyRows that were missing before the sender hashed the file
Row count against the sourceThe export held every row the source query returnedRows that are wrong, duplicated or out of date

A truncated file is shorter by definition, so the size check fails fast. Hashing and counting rows read every byte, so they take most of the time on a large delivery.

Which checksum algorithm should you use?

Use SHA-256 for the manifest. It belongs to the SHA-2 family specified in FIPS 180-4, the Secure Hash Standard, and the NIST Hash Functions page (updated 16 September 2026) lists it among the approved hash algorithms. The same page says NIST deprecated SHA-1 in 2011 and, in December 2022, published a plan to move away from its remaining uses.

MD5 still turns up in older delivery scripts. The Python hashlib documentation warns that MD5 and SHA1 have known collision weaknesses, which matters once the question is whether anyone changed a file. RFC 8493, the BagIt packaging format, requires tools to support SHA-256 and SHA-512 and keeps MD5 and SHA-1 for compatibility with older bags.

Cyclic redundancy checks such as CRC-32C and CRC-64/NVME are a separate family. The Amazon S3 user guide lists them beside the SHA algorithms and names CRC-64/NVME as its default. A CRC is an error-detecting code and does not appear among the hash algorithms NIST approves, so keep SHA-256 in the manifest as the record of what was sent.

How do you verify completeness and integrity end to end with a manifest of hashes?

End-to-end verification checks one manifest at every hop of the transfer. The sender computes hashes and counts before upload, the receiver checks them again after download and the warehouse load is checked against the same totals. The manifest lists each file's name, bytes, rows and SHA-256 hash, with the file count and total rows.

A sample manifest for a weekly delivery of three gzip-compressed CSV files, with illustrative hashes and figures:

{
  "delivery_id": "2026-11-09-weekly",
  "dataset": "illustrative_postings",
  "period": {"start": "2026-11-02", "end": "2026-11-08"},
  "algorithm": "sha256",
  "file_count": 3,
  "total_rows": 1048576,
  "files": [
    {"name": "part-001.csv.gz", "bytes": 61382227, "rows": 400000,
     "sha256": "bf191d9747d250fa45ae52031e97ac306831daf8e1add69815f1cf2d870fac3a"},
    {"name": "part-002.csv.gz", "bytes": 46040118, "rows": 300000,
     "sha256": "75d1e33c217eba2a4d908acac98bbc33983d1fae3adac05b83c7edd22ac72ac2"},
    {"name": "part-003.csv.gz", "bytes": 53507904, "rows": 348576,
     "sha256": "1231a10c4f391ac9e9b28cf6a9193cc1c0562e83d12b19d70d01176d041bcf5e"}
  ]
}

The rows figure should come from the source, such as the count the export query returned. A count taken from the finished file only repeats what the hash already proves.

RFC 8493, published in October 2018, keeps one manifest per algorithm, such as manifest-sha256.txt, with a line per file holding the checksum and the file path. It calls a bag complete when every file listed in its manifests is present, and valid when every checksum has also been verified against its file. Its Payload-Oxum field records the total bytes and the number of files, so a reader can spot an incomplete bag before running the checksum pass.

A manifest proves only that the files match the manifest. If it travels in the same folder as the files, anyone able to change a file can change its line too. When tamper evidence matters, send the manifest's own hash by a second channel or sign it. BagIt covers part of this with a tag manifest, which lists the checksums of the payload manifests.

How do you check the files from the shell?

On Linux, the GNU coreutils tool sha256sum writes the hashes and checks them. The sender runs the first command in the delivery folder and ships SHA256SUMS with the files:

sha256sum part-*.csv.gz > SHA256SUMS

The receiver runs the check after download, then confirms the number of files:

sha256sum --check --strict --quiet SHA256SUMS || exit 1
test "$(ls part-*.csv.gz | wc -l)" -eq 3 || exit 1

The GNU coreutils manual's sha2 utilities page says sha256sum accepts the cksum common options, which describe --check as reading checksums from the file and checking them, --strict as exiting non-zero when an input line is invalid and --quiet as dropping the OK printed for each good file. The GNU manual's md5sum page gives the exit status convention: zero for success, non-zero for failure.

Leave --ignore-missing out of a delivery check: the same GNU page says it stops the check failing or reporting on missing files, the very failure you want to see. The check reads only the files named in SHA256SUMS, so an extra part file would pass unnoticed, which is why the last line counts them.

How do you run the same check in Python before every load?

The script below reads manifest.json, checks each listed file for presence, size, SHA-256 and rows, reports any file the manifest does not list and exits with status 1 on any failure. Run it as the step before the load, so a scheduler that treats a non-zero exit as a failed task stops the pipeline there.

from csv import Error as CsvError, reader
from gzip import open as gzip_open
from hashlib import file_digest
from json import loads
from pathlib import Path
from sys import argv, exit, stderr

def sha256(path):
    with open(path, "rb") as f:
        return file_digest(f, "sha256").hexdigest()

def count_rows(path):
    opener = gzip_open if path.name.endswith(".gz") else open
    with opener(path, "rt", encoding="utf-8", newline="") as f:
        if ".jsonl" in path.name:
            return sum(1 for line in f if line.strip())
        return sum(1 for _ in reader(f)) - 1  # minus the header row

def check(folder):
    folder = Path(folder)
    manifest = loads((folder / "manifest.json").read_text(encoding="utf-8"))
    files = manifest["files"]
    errors, total = [], 0
    if len(files) != manifest["file_count"]:
        errors.append("manifest: file_count does not match its file list")
    for entry in files:
        path = folder / entry["name"]
        if not path.is_file():
            errors.append(f"missing: {entry['name']}")
            continue
        if path.stat().st_size != entry["bytes"]:
            errors.append(f"bytes: {entry['name']}")
        if sha256(path) != entry["sha256"]:
            errors.append(f"sha256: {entry['name']}")
        try:
            rows = count_rows(path)
        except (OSError, EOFError, CsvError, UnicodeDecodeError) as exc:
            errors.append(f"unreadable: {entry['name']} ({exc})")
            continue
        total += rows
        if rows != entry["rows"]:
            errors.append(f"rows: {entry['name']} has {rows}, expected {entry['rows']}")
    if total != manifest["total_rows"]:
        errors.append(f"rows: delivery has {total}, expected {manifest['total_rows']}")
    listed = {e["name"] for e in files} | {"manifest.json"}
    for extra in sorted(p.name for p in folder.iterdir() if p.is_file() and p.name not in listed):
        errors.append(f"not in manifest: {extra}")
    return errors

if __name__ == "__main__":
    problems = check(argv[1])
    for problem in problems:
        print(problem, file=stderr)
    exit(1 if problems else 0)

It relies on hashlib.file_digest, which the Python documentation (version 3.15.2) lists as added in Python 3.11. The function takes a file opened in binary mode and returns a digest of its contents. The CSV counter uses the csv module because a quoted field can hold a line break, so counting lines would overstate the rows.

How do you use S3's own checksums?

Amazon S3 computes and stores a checksum for each object, a second witness for any delivery that passes through a bucket. The S3 user guide lists ten algorithms, from CRC-64/NVME to SHA-512, and on its upload integrity page says S3 attaches a CRC-64/NVME checksum when an upload arrives without one. You can read the stored value without downloading the object:

aws s3api get-object-attributes \
  --bucket example-delivery-bucket \
  --key 2026-11-09-weekly/part-001.csv.gz \
  --object-attributes Checksum ObjectSize ObjectParts

Three details decide whether that value can be compared with your manifest:

  1. Encoding. The AWS CLI reference for get-object-attributes describes each checksum as Base64 encoded, while sha256sum and hexdigest print hexadecimal. Convert before comparing, for example with python3 -c "import base64,sys; print(base64.b64encode(bytes.fromhex(sys.argv[1])).decode())" <hex>.
  2. Checksum type. The response gives ChecksumType as FULL_OBJECT or COMPOSITE. In a multipart upload, SHA-256 is supported only as a composite checksum, built from the checksums of the parts, so it will differ from the SHA-256 of the whole file. CRC-64/NVME, CRC-32 and CRC-32C can serve as full object checksums.
  3. ETag. For an object uploaded in parts, the ETag is the MD5 of the concatenated part digests followed by a dash and the number of parts. Objects encrypted with SSE-KMS or SSE-C also carry an ETag that is not the MD5 of their data, and the console uploads files larger than 16 MB in parts.

Copying an object first uploaded in parts can also change its checksum value while the data stays the same. For data at rest, the Compute checksum operation in S3 Batch Operations calculates checksums for a list of objects in one job and returns a completion report. Keep SHA-256 in your own manifest and treat S3's stored checksum as evidence for the upload leg.

A worked example with one short file

Assumptions: Acme Robotics, an illustrative company, receives the weekly delivery in the sample manifest above, three gzip-compressed CSV files with 1,048,576 rows by the source count. Every figure is illustrative. The table shows four runs of the Python check, one clean and three with a fault.

RunWhat went wrongFile listBytesSHA-256RowsResult
ANothingPassPassPassPassLoad
Bpart-002 stopped at 30,000,000 of 46,040,118 bytesPassFailFailFailStop and ask for part-002 again
Cpart-003 never arrivedFailNot runNot runTotal failsStop and ask for part-003
DExport of part-003 timed out at 300,000 of 348,576 rows and was hashed afterwardsPassPassPassFailStop and rerun the export

Run D is the case a checksum cannot catch. The sender hashed the short file, so bytes and hash agree, but the source count of 348,576 rows exposes a gap of 48,576. Without that count, run D would have loaded 1,000,000 rows as the full week.

After a clean run, one query closes the loop in the warehouse. The count of rows loaded for the delivery must equal total_rows in the manifest:

SELECT COUNT(*) AS loaded_rows
FROM staging.postings
WHERE delivery_id = '2026-11-09-weekly';
-- expected: 1048576

A checklist to run before every load

  1. The manifest arrived, parses and matches the hash or signature sent by a second channel.
  2. The period in the manifest matches the period you asked for.
  3. The file count matches, every listed file is present and no unlisted file sits in the folder.
  4. Each file's size in bytes matches the manifest.
  5. Each file's SHA-256 matches the manifest.
  6. Each file's row count matches the source count, and the total matches total_rows.
  7. After the load, the table holds total_rows for the delivery and the keys that should be unique are distinct.
  8. On any failure, stop, keep the files and the manifest exactly as received and ask for the failed files again.

What can these checks not show?

A matching hash shows that a file is the one the sender hashed. It cannot show that the data inside is correct, current or complete for the companies you meant to cover, and it cannot catch an error made before the hash was computed. Row counts catch a short export but miss duplicates and wrong values, so also count rows against distinct keys, a test the Fokals comparison of API and bulk files recommends.

The checks built into storage and compression each cover one leg. S3's stored checksum covers the upload into the bucket. A gzip file carries a CRC-32 of the uncompressed data and its size modulo 2^32 in its trailer, but RFC 1952 says a decompressor need not examine the trailer, so a reader that skips it will report no mismatch.

Where do Fokals bulk deliveries fit?

Fokals delivers bulk exports as CSV or JSON Lines, and each packaged delivery comes with a manifest that names its sources, period, versions and licence, as the delivery page sets out. Fokals writes its daily and weekly datasets once, after each period closes, and does not revise them. A new period therefore arrives as new files, and the hashes you record for a closed period remain the reference for those files.

The checks above add a landing record of your own: the size, hash and row count of each file as it arrived, kept beside the manifest. The comparison of CSV, JSON Lines and Parquet also advises keeping the original files and their manifest. If you convert files to Parquet, verify the originals first, since a converted file has a hash of its own.

Frequently asked questions

Is MD5 good enough to verify a bulk data transfer?

An MD5 mismatch still flags a file that broke in transit, so old MD5 values remain useful for catching accidents. For evidence that nobody altered a file, use SHA-256: the Python hashlib documentation notes known collision weaknesses in MD5 and SHA1, and NIST deprecated SHA-1 in 2011. If an older process writes MD5, add a SHA-256 field beside it so past deliveries stay checkable.

Why does my SHA-256 differ from the checksum S3 shows?

There are three usual causes. S3 returns checksums Base64 encoded while sha256sum prints hexadecimal, so the same digest looks different until you convert it. An object uploaded in parts carries a composite SHA-256 built from the part checksums, which differs from the hash of the whole file. And copying an object first uploaded in parts can change its checksum value even though the data stays the same.

Should you hash the compressed file or the data inside it?

Hash the file exactly as it was transferred, which for a .csv.gz delivery means the compressed file. That is the object that moved, and it is what sha256sum and the Python check read. Take row counts from the decompressed records. The gzip trailer holds its own CRC-32 of the uncompressed data, but RFC 1952 does not require a decompressor to check it.

How do you verify a delivery that arrived with no hashes?

Record your own on arrival: the size, SHA-256 and row count of every file, stored beside whatever manifest came with it. Compare the file list and sizes with the sender's listing, compare row counts with the previous delivery for the same period length, and ask the sender for the source count of each file. From then on your landing record shows whether a file changed after it reached you.

Can a checksum prove that nobody tampered with a delivery?

Only when the expected hash reaches you by a route an attacker cannot also change. A manifest in the same folder as the files can be rewritten along with them, so send its own hash by a second channel or sign it. RFC 8493 also warns that older algorithms may not resist deliberate spoofing, which is one more reason to use SHA-256 or SHA-512.

The queries and code on this page are examples to adapt. Test them in your own environment before you rely on them.

What this page says about the products it names was checked against their public documentation on 16 November 2026. Product and company names are trademarks of their owners. Fokals is not affiliated with them or endorsed by them.