The question
When you make a working copy of a backup, how do you check whether the bytes stayed the same? This lab compares a short invented byte string with a copy and with a one-character edit. No Bitcoin wallet is opened.
Run the experiment
This is an original KeychainX exercise using invented data. It runs locally with Python 3 and makes no network requests. Download the script, read it, and run it in a folder used for practice.
Download backup_fingerprints.py
python backup_fingerprints.py"""Synthetic byte-integrity exercise. No wallet files or network access."""
import hashlib
original = b"bitcoinlabz practice backup\n"
copy = bytes(original)
changed = original.replace(b"practice", b"Practice")
digest = lambda b: hashlib.sha256(b).hexdigest()
print("Original:", digest(original))
print("Copy matches:", digest(copy) == digest(original))
print("Changed matches:", digest(changed) == digest(original))
assert digest(copy) == digest(original)
assert digest(changed) != digest(original)
Read the result
The copy comparison should print True. The changed comparison should print False. Changing the capital P changes the bytes, even though the sentence remains readable. SHA-256 gives a compact fingerprint of those bytes. A digest does not say whether a backup contains keys, is complete, belongs to you or opens with a particular password.
Apply the habit
- Preserve the original file and record its source before investigating.
- Hash the original and working copy with the same algorithm. Keep the digest and timestamp in a private investigation record.
- If the values differ, stop and establish whether the copy operation, an application or your own edits changed the file.
- Keep independent backups. Matching fingerprints are useful evidence, not a backup strategy.
Try one variation
Replace the final newline with a space in the invented byte string and run it again. The fingerprint changes. This is why opening a text-like backup and saving it through an editor can be a meaningful alteration. Do not perform that experiment on a real backup.