
Hashing for Forensics: Fingerprinting Files and Checking Them Against the World
Every cryptography lab I'd worked through before this one treated hashing as an integrity check: has this file changed since I last looked at it? This lab reframed the same tool for a different discipline entirely. In digital forensics, a hash isn't just a change detector, it's a compact, searchable fingerprint, small enough to index and compare at scale, and specific enough to look up against a global database of known malicious files.
Every cryptography lab I'd worked through before this one treated hashing as an integrity check: has this file changed since I last looked at it? This lab reframed the same tool for a different discipline entirely. In digital forensics, a hash isn't just a change detector, it's a compact, searchable fingerprint, small enough to index and compare at scale, and specific enough to look up against a global database of known malicious files. The investigator's problem the lab opened with was practical: malware samples are often huge, too large to search or index efficiently as raw files, so instead of storing and comparing the actual code, you hash it, and search for the hash.
Three Kinds of Hashing in One Lab
I worked through HashCalc for three distinct purposes: plain file hashing, HMAC (keyed hashing), and hashing a text string directly, before finishing with a genuinely practical forensic exercise, checking a suspicious file's hash against VirusTotal's malware database.
Plain file hashing
Starting with a sample evidence image file, I selected it in HashCalc with multiple hash algorithms checked simultaneously, MD5, MD4, SHA1, SHA512, and MD2, and calculated all of them in one pass. Each algorithm produces a completely different output for the same file, which is expected and useful rather than redundant: having several hash values for the same evidence file gives an investigator multiple independent fingerprints, useful because different tools, databases, or legal contexts may standardize on different algorithms. A hash database you're checking against might only index MD5; another might use SHA1. Computing several at once means you're covered regardless of which one ends up mattering later.
HMAC: hashing with a shared secret
The second exercise introduced something meaningfully different: HMAC, Hash-based Message Authentication Code. Rather than hashing the file alone, HMAC combines the file's content with a secret key before producing the output. I checked the HMAC box, selected Text String as the key format, supplied a key, and selected several algorithms again.
The distinction between a plain hash and an HMAC matters more than it might look like at first. A plain hash proves a file hasn't changed, but anyone with access to the file can recompute that same hash themselves, there's no secret involved, so a plain hash alone can't prove who generated it or vouch for anything beyond "this content matches." An HMAC, by contrast, can only be correctly recomputed by someone who also has the shared key. That means an HMAC can serve a second purpose a plain hash can't: proving that whoever generated it actually possessed the secret key, not just that they had access to the file. In a forensic chain of custody, that distinction, integrity alone versus integrity plus a form of authentication, can matter quite a bit.
Hashing a text string directly
The third exercise was more straightforward but worth noting for a specific reason: HashCalc doesn't require an actual file on disk at all. I switched the Data Format to Text String, typed a short message directly into the Data field, and hashed it the same way. That's a reminder that hashing isn't inherently tied to files, it's a general operation on any data, text, a password, a short message, anything that can be represented as bytes. In forensics specifically, this matters for things like verifying a recovered chat message or log line matches a known reference value, without ever needing it saved as a standalone file.
The Actual Forensic Payoff: Checking a Hash Against VirusTotal
The most genuinely useful part of the lab came last. I hashed a file named
Infected.pdf , deliberately included in the evidence set as a known-suspicious sample, computing its MD5 value specifically.Then, instead of uploading the actual file anywhere, I took just that MD5 hash and searched it directly on VirusTotal, a malware-scanning aggregator that checks submitted files or hashes against dozens of different antivirus engines simultaneously.
This is the exact mechanism the lab's opening scenario was describing. Rather than uploading a potentially sensitive, possibly huge file to a third-party service, or needing to store and transmit the file's full content at all, a hash lookup lets you check whether a specific, already-known file has been previously identified as malicious, using nothing but a short fixed-length string. VirusTotal returned a clear result: a significant number of its antivirus engines flagged the file as malicious.
From there, I explored two further tabs VirusTotal provides beyond the simple detection count. The Details tab showed the file's basic properties, confirming its MD5, SHA-1, and SHA-256 values together (useful for cross-referencing against other systems that might use a different algorithm than the one I originally searched with). The Behavior tab went further, surfacing what the file actually does when analyzed in a sandboxed environment: file system actions, registry actions, process and service actions, the kind of dynamic analysis that goes beyond "is this hash on a blocklist" and starts answering "what would actually happen if this ran."
Why Hash-Based Lookup Matters in Practice
A few things stood out, thinking about why this workflow is actually standard practice in forensics and incident response, not just a convenient trick.
Hash lookup avoids handling the actual malicious content directly. Searching a hash means you never have to upload, transmit, or even keep the suspicious file itself accessible to a third-party scanning service. For sensitive investigations, or simply to avoid the operational risk of handling live malware more than necessary, that's a meaningful advantage over uploading full files everywhere.
A hash is a compact index into a massive, distributed body of threat intelligence. VirusTotal's value isn't that it has one clever detection algorithm, it's that it aggregates results across dozens of independent antivirus engines, each with its own detection logic and threat database. A single MD5 lookup effectively queries all of them at once, something that would be completely impractical to replicate by running every individual antivirus product yourself.
Multiple hash algorithms exist for genuine compatibility reasons, not redundancy. Different tools, databases, and legal/forensic standards gravitate toward different algorithms. Calculating MD5, SHA1, and others simultaneously isn't excessive, it's what makes a single piece of evidence usable across whatever system you need to check it against next.
HMAC adds a dimension plain hashing can't: proof of possession of a secret. That's a genuinely different guarantee than integrity alone, and recognizing when a scenario calls for HMAC instead of a plain hash (anywhere you need to prove not just "unchanged" but "generated by someone who held this specific key") is a real forensic and security engineering distinction, not just an extra checkbox in the tool.
This connects directly to the broader hashing concepts covered elsewhere. A plain hash from this lab behaves exactly like the integrity-checking hashes from an earlier cryptography module, a tiny input change produces a completely different output. What's different here isn't the underlying mechanism, it's the application: instead of asking "has this one file I already trust changed," the question becomes "has anyone else, anywhere, already seen and flagged this exact file before."
This lab reframed something I'd already understood mechanically, hash functions and their core properties, into a genuinely different professional use case. A forensic investigator doesn't hash a file to watch it for future changes; they hash it to ask a question against a database they didn't build: has anyone else already seen this exact file, and if so, what did they conclude about it? That reframing, from "integrity check on something I already trust" to "fingerprint lookup against a global threat database", is really the whole point of hash-based malware triage, and it's a genuinely efficient technique precisely because a short, fixed-length hash can travel, index, and search in ways that a large, potentially sensitive raw file never could.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article