In-depth practical guides

Calculate and compare a file’s SHA-256 digest

Matching names, sizes or appearances do not establish identical versions. A SHA-256 digest represents file bytes. It helps detect changes without establishing authorship, creation date or truth of the contents.

Updated :

Backup drive and verification notebook. Illustrative scene.

AI-generated illustration

Is the received file identical to the preserved one?

Digest comparison starts with the exact file, algorithm and expected reference. Saving again, changing encoding or adding a line ending can alter bytes without an obvious on-screen difference. Keep integrity checking separate from checking origin.

  1. Select the exact record

    Use the preserved original. Printing to PDF, exporting or recompressing an image can preserve meaning while changing bytes. Compare equivalent objects.

  2. Establish the reference

    Calculate SHA-256 with a checker suited to your environment. Compare complete digests and confirm that the checked file is the intended version.

  3. Calculate and compare

    Calculate SHA-256 for each selected file and compare all 64 hexadecimal characters. Check the algorithm on both sides; an initial digest fragment or file size alone is insufficient.

  4. Keep the record

    Record the algorithm, full digest, byte size, file and check time in your register. Add the origin of the expected reference and the collection date, separate from calculation time.

  5. Interpret differences

    With the same algorithm and correct calculations, different digests indicate different bytes. Investigate a new version, transformation or wrong file. Do not automatically infer forgery.

Guided reading of an excerpt

A line feed changes the digest

A uses NIST’s test message abc without a line ending. B adds one LF byte. The visible strings may appear identical, but A contains three bytes and B four.

Fictional exercise: identifiers, values and dates illustrate the check. This excerpt is not a live collected response.

  1. Fix the bytes

    A: hexadecimal 61 62 63. B: 61 62 63 0a. No BOM, space or carriage return is added.

  2. Compare complete values

    Both calculations use SHA-256. The digests below differ even if an editor hides the line ending.

  3. Explain the difference

    Here LF explains the change; it does not establish forgery. For a real document, investigate the transformation before concluding.

Two test messages, not versions of a real document

A (3 bytes): 61 62 63
SHA-256: ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad

B (4 bytes): 61 62 63 0a
SHA-256: edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb

What to inspect

A: three bytes
The result matches NIST’s published abc test vector.
B: four bytes
The result applies to abc followed by LF, not to the three characters abc alone.
Does renaming A’s file change its SHA-256?

Reasoning

No, if only the name or path changes and the bytes remain intact. Saving again in an editor can change encoding, BOM or line endings; check the actual transformation.

Official references : NIST · SHA-256 example values

Situations and decisions

Typical situations for preparing a check. They do not describe completed assignments or actual observations.

Renamed file

Renaming alone does not change the content digest. Keep both names and check the selected object.

Re-exported PDF

Pagination or metadata may change on export. Digests can differ while the quoted passage appears unchanged; compare text and version.

Digest supplied with the document

Agreement checks consistency between digest and file. Sender identity and document origin need separate checks.

Worked exercise

Identical names, different versions

Fictional example: the values and documents teach the method and do not describe a real organisation.

The calculated hashes differ, but the first-page passage looks identical. Full hash values are not reproduced in this table.

If the table exceeds the screen, scroll horizontally; arrow keys work when the region is focused.

Starting information
Storage folderFile nameSHA-256 comparison
Arapport.pdfDifferent from folder B’s
Brapport.pdfDifferent from folder A’s

Your checks

  1. Associate each hash with the selected file.
  2. Compare version, size and cited passage.
  3. Separate binary difference from conclusion difference.
Read the answer

Answer and decision

Different hashes establish different bytes. They do not establish the official version or whether the claim changed. Read the passage and both objects' provenance; do not substitute files merely because names match.

If the case changes

A hash matching one published by a source also needs a correctly identified source reference. Extend the test by renaming a copy without changing its bytes: its digest stays the same. The filename is not part of the hashed content. Keep provenance and acquisition date separately; a digest does not certify the document’s author.

Record to retain

Keep name, working path, size, hash, origin and passage location.

Documentation reference : NIST — FIPS 180-4, Secure Hash Standard · Consulted on

Record to retain

  • SHA-256 algorithm, digest, name and byte size.
  • Expected digest and its source where available.
  • Collection date separate from local calculation time.
  • Known transformation, comparison result and record.

Official references

Related source profiles

Related protocols

Checks before reaching a conclusion

  • Does the expected digest have an identifiable source?
  • Are collection and calculation times distinct?
  • Are differences investigated without automatic accusations?

Frequently asked questions

Which object should be checked?

The exact file retained or transmitted, in its actual format. Text copied from a PDF and the PDF itself are different objects even if the passage looks identical.

Does an equal digest prove the document is true?

No. Incorrect information retains a stable digest while its bytes stay unchanged. Check source, author, context and content separately; the digest identifies the version reviewed.

How is it possible to check locally?

Choose a tool that reads file bytes using SHA-256. In PowerShell, Get-FileHash accepts -Algorithm SHA256 and -LiteralPath. Record the complete result and confirm the selected file.

DOCUMENTED REFERENCE

WARC: distinguish two digests and two lengths

WARC 1.1 distinguishes a record block from its payload. Lengths 1902 and 1662 come from the response example in Annex B; they are documentation values, not measurements recalculated here on an available file.

WARC: distinguish two digests and two lengths
ReferenceValue or formWhat it identifies
WARC-Block-Digestalgorithm:digestAn optional digest of the entire record block. For application/http, this includes the encapsulated HTTP response, not the outer WARC headers.
WARC-Payload-Digestalgorithm:digestAn optional digest of the payload contained or referenced. For application/http it covers the entity body; a revisit’s payload may be absent from the current block.
WARC · Content-Length1902In the specification’s example, byte length of the WARC block containing the HTTP response. It is not the total size of a .warc.gz file.
HTTP · Content-Length1662In that same example, the declared length of the encapsulated JPEG body. It differs from the block length, which also includes HTTP headers.
WARC-Refers-ToWARC-Record-IDReferences another record’s identifier, including in revisits. Resolve the reference and check the profile before claiming to hold a complete payload.
WARC-Truncatedlength / time / disconnect / unspecifiedSignals truncation and its reason. Content-Length still describes the stored block’s actual size; consistent length does not establish capture of the whole resource.

Implication for the record

Do not directly compare these digests with a compressed container or replayed file’s checksum. Record algorithm, value encoding, covered bytes and decompression or extraction. A valid digest does not establish authorship or factual accuracy.

Do different block digests prove a text change?

No. Encapsulated headers can differ, and segmentation changes blocks. Examine the relevant payload after documented extraction, then compare the passage actually used.

Primary documentation

Documentation consulted on .

DOCUMENTED REFERENCE

RFC 3161 timestamps: identify what the token actually dates

A timestamp token binds a digest to a time indication signed by a time-stamping authority, or TSA. RFC 3161 separates existence of bytes from document authorship dates and factual truth.

TimeStampToken · CMS SignedDataTSTInfomessageImprint + genTime + …
RFC 3161 timestamps: identify what the token actually dates
ReferenceValue or formWhat it identifies
messageImprinthashAlgorithm + hashedMessageAlgorithm and digest of the submitted data. Recalculate on the exact item to check the match; the TSA need not receive the document itself.
genTimeGeneralizedTime · UTCToken creation time according to the TSA, encoded in UTC. It is neither first publication nor the time of events described in the file.
accuracyseconds / millis / microsTime deviation around genTime. This optional field’s absence does not imply perfect precision; the TSA policy may supply the information.
orderingFALSE / TRUEWithout true ordering, genTime orders two tokens only if their separation exceeds the sum of their accuracies. True ordering enables ordering tokens from the same TSA.
nonceTimeStampReq ↔ TSTInfoIf present in the request, it must be copied unchanged into the response. It links response to request and is not a date.
policyTSAPolicyIdIdentifier of the policy under which the token was issued. Retain its version to interpret accuracy and service commitments.
serialNumberTSAToken number assigned by the TSA, unique within that authority. It is neither a universal document identifier nor a public publication counter.

Compare two timestamp times

Initial values are for teaching; no actual observations are preloaded. For absent or false ordering, with documented uncertainties. Values from 0 to 86,400 seconds, up to six decimals; decimal point or comma, no thousands separators. Unknown uncertainty is not zero. This calculation validates neither tokens nor signatures.

Teaching example: 3 s gap, uncertainties of 1 s and 1 s. Since 3 > 2, the order is distinguishable by this criterion.

Implication for the record

Also validate the token signature, TSA certificate and trust context. Retain token, checked file, algorithm, result and validation date. Format conformity alone establishes neither a particular legal status nor factual accuracy.

Can a PDF’s displayed date date a signature?

A claimed date and a signed token are different objects. Identify the data covered, verify its digest and retain the validation result before using the token time.

Primary documentation

Documentation consulted on .

DOCUMENTED REFERENCE

Signed PDFs: identify the revision and covered bytes

A signature image, typed name or visible stamp does not establish a validated digital signature. PDF structure and validator reports distinguish appearance, cryptographic coverage and later changes.

Signed PDFs: identify the revision and covered bytes
ReferenceValue or formWhat it identifies
/ByteRangeoffset / lengthDescribes byte ranges covered by the signature. The validator checks consistency and placement of the signature-value exclusion; the first number alone is insufficient.
/ContentsCMSContains the signature value, generally CMS for PAdES. This structural field is not the signature drawing displayed on a page.
/MPDF dateClaimed date in the signature dictionary. It does not replace a validated timestamp or alone establish document authorship time.
incremental updateappendAn incremental update appends a revision without rewriting all earlier bytes. Successive signatures can cover different revisions of the final file.
/DocMDPP = 1 / 2 / 3Certification-signature parameters governing permitted changes. Distinguish form filling, signing and annotations; apply the PDF version and profile rules rather than visual comparison alone.
/FieldMDP/FieldsForm-field restrictions, separate from document permissions. Check which fields are affected before concluding the entire form was frozen.

Implication for the record

Retain the received file unchanged and inspect each signature result, covered revision and detected changes. Printing or re-export can lose this structure. Whole-file SHA-256 matching and signature validation answer different questions.

If the first signature remains valid, is the latest version fully approved?

Not automatically. Examine the covered revision, subsequent additions and permissions. Validation of signed bytes must not be restated as approval of every later addition.

Primary documentation

Documentation consulted on .

DOCUMENTED REFERENCE

Base64: check alphabet, padding and unused bits

Base64 represents bytes using ASCII characters. It is neither encryption nor a digest: decoding recovers the data. The seven RFC 4648 vectors below are public references with no real secret.

666F6FZm9v3 × 8 bits = 4 × 6 bits

The three hexadecimal bytes 66 6F 6F represent foo and become four Base64 symbols Zm9v. The 24 bits are regrouped in sixes.

Base64: check alphabet, padding and unused bits
ReferenceValue or formWhat it identifies
ALPHABETA–Z · a–z · 0–9 · + /Classic Base64 uses + and / for values 62 and 63. Read a value using its protocol’s alphabet, without silently replacing characters.
base64url62: - · 63: _Base64url replaces these signs with - and _. The name identifies a different alphabet; alone it does not determine whether = may be omitted.
QUANTUM3 bytes → 4 symbolsEach complete group of three bytes produces four symbols. Encoded length is neither file size nor the character count of decoded text.
PADDING1 byte: == · 2 bytes: =One final byte requires two = signs; two final bytes require one. Omitting padding requires an explicit calling protocol contract. Do not accept an arbitrary truncated ending.
PAD BITS0Unused bits in the final symbol must be zero for canonical encoding. A permissive decoder may recover identical bytes from another spelling; this reader rejects noncanonical forms.
NON-ALPHABETreject by defaultThe general rule rejects non-alphabet characters including line breaks unless the protocol defines an exception. This reader is strict: no spaces or returns are removed.

Inspect a Base64 value

Decoding stays in this page. Initial example: foobar, a public RFC 4648 vector. No file is uploaded.

Maximum 1024 characters. Spaces and line breaks rejected. Unused bits must be zero. An empty string represents zero bytes.

Encoding conforms to the selected profile.

Byte count : 6

Decoded hexadecimal bytes

66 6F 6F 62 61 72

UTF-8 reading, if valid

foobar

An initial UTF-8 marker is preserved in bytes and decoded text.

Published vectors and reference data

Published vectors and reference data — RFC 4648 § 10
Source (ASCII)Published Base64HexadecimalBytes
""""—0
"f""Zg=="661
"fo""Zm8="66 6F2
"foo""Zm9v"66 6F 6F3
"foob""Zm9vYg=="66 6F 6F 624
"fooba""Zm9vYmE="66 6F 6F 62 615
"foobar""Zm9vYmFy"66 6F 6F 62 61 726

Documentation examples; no observations of this site. RFC 4648 § 10. Copyright © 2000–2006 Simon Josefsson.

Attribution and reuse conditions
15.  Copying Conditions

   Copyright (c) 2000-2006 Simon Josefsson

   Regarding the abstract and sections 1, 3, 8, 10, 12, 13, and 14 of
   this document, that were written by Simon Josefsson ("the author",
   for the remainder of this section), the author makes no guarantees
   and is not responsible for any damage resulting from its use.  The
   author grants irrevocable permission to anyone to use, modify, and
   distribute it in any way that does not diminish the rights of anyone
   else to use, modify, and distribute it, provided that redistributed
   derivative works do not contain misleading author or version
   information and do not falsely purport to be IETF RFC documents.
   Derivative works need not be licensed under similar terms.

Implication for the record

Three explicit profiles: classic padded, URL padded and URL unpadded. They inspect syntax and bytes without establishing token or signature validity.

Is well-formed Base64 safe or authentic?

No. It may contain any bytes, including misleading text. Encoding validity establishes neither sender, access rights nor content meaning.

Primary documentation

Documentation consulted on .

DOCUMENTED REFERENCE

HMAC: what a shared key changes

An unkeyed digest and a keyed authentication code provide different information. Two RFC 4231 cases make the distinction verifiable with explicit test bytes.

HMAC: what a shared key changes
ReferenceValue or formWhat it identifies
SHA-256message → digestA plain SHA-256 digest depends on the message. Anyone holding the same bytes can recompute it; publishing file and digest together does not automatically identify an author.
HMAC-SHA-256key + message → MACHMAC-SHA-256 depends on key and message using the HMAC construction. It is not simply SHA-256 of text prefixed by a password, nor another spelling of an existing digest.
KEYshared secretVerification needs the same secret key. A party knowing that key can also produce valid codes, so the result does not publicly attribute a message to just one group member.
RFC 4231 §4.220 key bytes · 8 data bytesThe first vector uses twenty bytes of hexadecimal 0b and the eight ASCII bytes of Hi There. Its public test key is not a recommendation for creating secrets.
RFC 4231 §4.34 key bytes · 28 data bytesThe second uses ASCII key Jefe and twenty-eight data bytes. Hexadecimal cells specify exact bytes without quotes, line endings or extra characters.
PROVENANCEMAC ≠ public signatureA valid MAC replaces neither a public-key signature nor provenance analysis. It does not date the message or, alone, prevent replay of an old valid request.

Two published HMAC-SHA-256 vectors

RFC 4231 cases 1 and 2. Key, data and result in hexadecimal; public test keys.

Two published HMAC-SHA-256 vectors
CaseKey (hex)Data (hex)HMAC-SHA-256 (hex)
10b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b4869205468657265b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7
24a6566657768617420646f2079612077616e7420666f72206e6f7468696e673f5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843

RFC 4231 §§ 4.2–4.3. Copyright © 2005 The Internet Society.

Implication for the record

Displayed keys are public test vectors. No key input is requested; tables document reference results without authenticating real documents or APIs.

Is it possible to replace an HMAC with a file’s SHA-256 digest?

No. Retain the expected construction and contract: algorithm, key, covered bytes and contextual fields. Equal-length results can serve different functions.

Primary documentation

Documentation consulted on .

DEEPER READING / PRACTICE

Use a hash to verify content identity

Two files have the same name, or a document must be preserved for a later check. A cryptographic hash compares their content without relying on the displayed name or date.

Updated on .

Priority checks

Calculate the hash of the file concerned and keep the algorithm, size and reference. Compare with the expected value under the same conditions.

Interpretation pitfalls

An identical hash does not demonstrate the author or the authenticity of the document. A change in metadata or format can change the hash without changing the apparent meaning.

Working record to retain

The report retains file, algorithm, value, date and comparison result. It is included in a source chain that also describes the origin and use of the document.

PRACTICAL CASE / WORKED EXAMPLE

The name is the same, the content has changed.

The example below is pedagogical. It shows how to move from a document to a qualified proposal, preserving the context, the contradictory elements and the information that the research does not yet allow to establish.

Example context

Two files uploaded to different dates carry the same name. Their content does not match exactly, but the visual comparison does not allow to quickly place the difference.

Suggested approach

Calculate the footprints with the same algorithm and keep size and dates. Then compare structure and passages when the meaning of the change counts for the file.

Conclusion and next step

The hash difference indicates a difference in binary content. Its documentary importance is examined separately, without automatically concluding to a substantial modification or falsification.

Questions for deeper practice

Is there a trace to find the author?

It is used to compare the identity of the content according to the algorithm used. The author, origin and authenticity require other elements of origin and are not determined by the value alone.

DETAILED WORKSHOP / APPLICATION

Link the content check to a provenance record

  1. 01 / Prepare the necessary information

    Prepare file, algorithm, expected value and collection context. Identify the exact compared object to avoid mixing original and variant.

  2. 02 / Carry out the approach

    Calculate the hash and keep size, date and result. Compare in the same conditions. If the values differ, then examine the structure or content according to the documentary need.

  3. 03 / Examine an alternative situation

    If the footprints are identical, make a conclusion on the identity of the compared content. Truthfulness, author and origin remain questions that require other elements.

  4. 04 / Decide on the next step

    Control is complete when file and method are identified. A binary difference must be interpreted separately from its importance for the meaning or proof.

  5. 05 / Hand over the verification records

    Transfer file, value and source report. Subsequent comparisons may confirm the preserved status without attributing a broader scope of authentication.

ANNOTATED WORKING DOCUMENT / REVIEW GRID

A content identity report with a collection context

The report retains the exact file, algorithm, size, date and value. It connects the comparison to the source without attributing to the hash a general authentication scope.

On a small screen, scroll the grid horizontally to read all three columns.

Example situations to assess
ObservationSupported interpretationNext step
The footprints are identical under the same conditions.The identity of the compared content can be described according to the algorithm.Keep the references and other sources.
The footprints differ despite the same name.The files do not present the same binary content.Consider the difference of structure or meaning according to the need.
The value is used to affirm the author.The binary identity does not demonstrate this attribution.Find the documentary that is adapted to the original.

Reviewing the working document

The final verification must identify exactly the compared files. A format or metadata transformation can change the hash without establishing itself a significant change in the word.

REPORTING / EXAMPLE WORDING

Presentation of results: Use a hash to verify the identity of the content

Point to clarify

The identity of the content must not receive an additional authentication scope.

Before handing over

Identify the exact objects and qualify separately the importance of a binary difference.

Example of a qualified conclusion

The calculated values compare the files and the algorithm indicated. The origin and claims about the author are based on distinct elements.