π Master your Security+ skills with Pluralsight here: Pluralsight
Youβll learn what cryptographic hashing is, how SHA-256 helps verify file integrity, and why secure password storage needs salts and specialized hashing. Build your CompTIA Security+ foundation by understanding hashing vs. encryption, and why a matching hash doesnβt prove a file is safe.
Chapters: 0:00 Intro 0:13 What does cryptographic hashing actually do? 1:00 What makes a cryptographic hash secure? 1:56 How do hashes detect changed files and logs? 3:05 How can websites check passwords without decrypting them? 3:49 Does hashing prove who sent something? 4:28 Outro
Affiliate notice: Some links may earn a commission. Thanks for your support.
Key Takeaways
Hashing creates a fixed-length digest of exact input bytes. The same input and algorithm always produce the same result; even a small change typically produces a dramatically different digest.
SHA-256 produces 256 bits, usually displayed as 64 hexadecimal characters. Avoid MD5 and SHA-1 for applications requiring collision resistance; see NISTβs hash guidance.
Verify downloads against a trusted publisherβs full digest. In PowerShell, use Get-FileHash -LiteralPath ".\download.iso" -Algorithm SHA256 and compare the result with the expected value.
A matching hash supports integrity, not safety or authenticity. Malware can match its published hash, and attackers who replace both a file and its reference digest can defeat a simple comparison.
Password storage needs specialized hashing, not plain SHA-256. Use a scheme such as Argon2id with unique random salts and appropriate cost settings; follow OWASPβs password-storage guidance.
Hashing is not encryption. Encryption protects confidentiality; HMAC adds shared-secret authentication; digital signatures support verification using a public key.
π Turn understanding into hands-on skills with Pluralsight, an optional next step offering guided security labs, feedback, assessments, and certification practice.
Cryptographic hashing turns data into a compact value called a hash or digest. It helps you check whether a file has changed, supports secure password verification, and forms part of mechanisms such as digital signatures.
The important limitation: a matching hash does not prove that a file is safe. It supports a comparison with a reference, not a judgment about whether the content is trustworthy.
Hereβs cryptographic hashing explained through its core properties, practical file checks, and role in password protection.
What Is Cryptographic Hashing?
A cryptographic hash function takes input data and calculates a digest. For conventional algorithms, the output has a fixed length regardless of the inputβs size.
Some links may earn a commission. Thanks for your support.
Watch in the video playerOpen the dedicated player for this course.
The relationship looks like this:
digest = H(input)
Here, H represents the chosen hash function. The input might be a sentence, a configuration file, an application installer, or a disk image.
A useful analogy is a digital fingerprint of the exact input bytes. However, unlike an ideal unique identifier, a hash is not guaranteed to belong to only one possible input.
SHA-256 and Fixed-Length Output
SHA-256 is a widely encountered member of the SHA-2 family. Its output is:
256 bits
32 bytes
Usually displayed as 64 hexadecimal characters
Hexadecimal uses the digits 0β9 and letters aβf. It is simply a way to display the digest, not a form of encryption.
For the exact text Hello, World!, without a trailing newline, the SHA-256 digest is:
A small text file and a large download both produce a 64-character hexadecimal SHA-256 digest. The larger file still takes more data processing; fixed output length does not mean fixed processing time.
How Does Cryptographic Hashing Work?
At a practical level, hashing follows three steps:
Read the input bytes.
Process them using the algorithmβs defined mathematical operations.
Produce the final digest.
Hash algorithms such as SHA-256 process data in blocks. Tools can therefore hash large files incrementally rather than loading the entire file into memory.
The result depends on the exact bytes, not what the content appears to mean. These are different inputs:
Hello
hello
Hello!
An extra space, a trailing newline, or a different text encoding can also change the digest.
Determinism and the Avalanche Effect
Cryptographic hash functions are deterministic: the same exact input, processed with the same algorithm, always produces the same digest.
They are also highly sensitive to input changes. A small change typically produces a dramatically different-looking output. This is called the avalanche effect.
It does not mean every output bit must change whenever an input bit changes. It describes how input differences spread throughout the output.
What Makes a Cryptographic Hash Secure?
A secure cryptographic hash function should make three kinds of attack computationally impractical.
Security property
What it should make difficult
Preimage resistance
Starting with a digest and finding an input that produces it
Second-preimage resistance
Starting with a particular file and finding a different file with the same digest
Collision resistance
Finding any two different inputs that produce the same digest
These properties address different problems. Finding a collision does not automatically mean an attacker can recover a password or replace any chosen file.
Why Hash Collisions Must Exist
A fixed-length digest has a limited number of possible values, while the space of possible inputs is much larger. Consequently, some different inputs must produce the same digest. These matches are called collisions.
Security does not depend on collisions being impossible. It depends on useful collisions being infeasible to find.
Algorithm choice matters here. MD5 and SHA-1 have broken collision resistance and should not be selected for new applications that require it. SHA-256 is a modern option commonly used for file-integrity checks. NISTβs Hash Functions project provides background on hash algorithms and their security properties.
How to Verify File Integrity With SHA-256
A file-integrity check compares a newly calculated digest with a trusted expected digest.
For a download, the process is:
Obtain the publisherβs expected SHA-256 digest for the exact release.
Download the file.
Calculate the fileβs SHA-256 digest.
Compare the full values.
On Windows, PowerShell provides a built-in command:
With an appropriate algorithm and a trustworthy reference:
Matching digests provide strong evidence that the checked bytes match the reference bytes.
Different digests mean the inputs differ.
A mismatch does not explain the cause. It could indicate corruption, tampering, an incomplete download, or simply the wrong version.
A content-hashing tool checks file contents rather than the filename. Renaming a file without changing its contents therefore does not change its content hash.
Why the Reference Hash Must Be Trusted
If attackers replace both a download and its published hash, the malicious replacement can pass a simple comparison.
Obtain the expected digest through a trusted publisher channel. Where available, a properly verified digital signature can additionally connect an artifact to a signing key.
Most importantly, integrity is not the same as safety. Malware has a hash too. Matching a reference does not establish that the original file was harmless, truthful, or authorized.
How Hashing Supports Log Integrity and Digital Evidence
The same comparison principle supports file-integrity monitoring and digital investigations.
Investigators can record an evidence fileβs digest, preserve it securely, and check it later to detect changes. The reference digest needs protection: storing it where an attacker can freely replace it undermines the comparison.
Logs require additional care because they grow over time. Hashing an active log today does not protect entries added tomorrow. Protected archived snapshots, batches, or authenticated logging structures may be needed.
Hashing is one component of a larger process. Access controls, secure storage, and documentation of evidence collection and handling still matter.
How Websites Verify Passwords Without Decrypting Them
A properly designed password system stores a password-derived verifier, rather than storing the plaintext password.
A simplified process works like this:
During registration, generate a unique random salt.
Process the password using a suitable password-hashing scheme, the salt, and cost settings.
Store the verifier and required nonsecret parameters.
At login, repeat the calculation using the submitted password.
Compare the calculated result with the stored verifier.
There is no password decryption step.
Why Plain SHA-256 Is Not Enough
General-purpose SHA-256 is designed to be fast. That is useful for checking large files, but it is undesirable for password storage.
If attackers steal a password database, they can hash candidate passwords and compare the results offline. The websiteβs normal login rate limits do not constrain those offline guesses.
Password storage therefore needs a deliberately costly scheme, such as Argon2id. Other options include scrypt, bcrypt for legacy situations, and PBKDF2 in relevant environments. The OWASP Password Storage Cheat Sheet explains these choices.
Salts and Cost Settings Serve Different Purposes
A salt is a unique, randomly generated value supplied to the password-hashing scheme.
Salts:
Do not need to be secret.
Prevent identical passwords from trivially producing identical stored verifiers across accounts.
Defeat reusable precomputed lookup tables.
Cost settings make each password guess more expensive. Memory-hard schemes also impose memory costs.
Neither measure makes a weak password unguessable. An attacker may still discover a predictable password by trying it. That is guessing and comparison, not decrypting or reversing the hash.
Hashing vs. Encryption, HMAC, and Digital Signatures
These mechanisms solve different security problems.
Anyone with a file and the algorithm can calculate its ordinary hash. A digest alone therefore does not prove who created or sent the file.
HMAC adds shared-secret authentication. Digital signatures use a different trust model: a private key creates the signature, and a corresponding public key verifies it. Establishing who controls that key remains part of the surrounding trust process.
For a Security+ foundation, keep the boundaries clear: hashing supports integrity checks, encryption protects confidentiality, and authentication requires more than an ordinary public digest.
Practice Cryptographic Hashing With Python
This short exercise demonstrates how capitalization and newlines affect SHA-256:
import hashlib
samples = [b"Hello", b"hello", b"Hello\n"]
for sample in samples:
digest = hashlib.sha256(sample).hexdigest()
print(repr(sample), digest)
The b prefix creates byte strings. The hexdigest() method displays each digest in hexadecimal.
Run the example and compare the three outputs. Each is 64 hexadecimal characters long, but the values differ because the inputs differ.
This is a demonstration of general-purpose hashing, not a password-storage implementation.
Build Hands-On Cybersecurity Skills
Understanding a digest is a useful starting point. Applying that knowledge means choosing the right algorithm, protecting the reference value, and recognizing what a comparison does, and does not, prove.
For guided practice beyond the foundations, Pluralsight offers security labs, feedback, assessments, and practice exams to help you identify gaps and focus your certification preparation.
Affiliate notice: Some links may earn a commission. Thanks for your support.
SHA-256 vs. MD5: What Makes a Hash Secure? (Explained Clearly)Next
FAQ
Quick answers to the questions people usually ask about this topic.
How do I check a fileβs SHA-256 hash on macOS or Linux?
On macOS, open Terminal and run:
shasum -a 256 "download.iso"
On most Linux distributions, run:
sha256sum "download.iso"
Replace download.iso with your fileβs path. Compare the entire resulting digest with the SHA-256 value published through the software publisherβs trusted channel. A match supports file integrity; it does not prove the download is harmless.
Should a ZIP archive have the same hash as the file extracted from it?
No. A ZIP archive and an extracted file contain different bytes, so their SHA-256 hashes will normally differ. Compare the publisherβs expected digest with the exact artifact it describes, for example, the downloaded ZIP rather than an installer inside it. Recompressing the same files can also produce a different archive hash if compression settings or embedded metadata change.
Does uppercase or lowercase matter when comparing SHA-256 hashes?
Letter case does not change the value of a hexadecimal digest: AβF and aβf represent the same hexadecimal digits. Compare all 64 characters of a SHA-256 digest, ignoring display case. This differs from changing capitalization in the original input text, which changes the input bytes and typically produces a completely different digest.
What should I do if a downloaded fileβs hash does not match?
Do not run or install the file until you resolve the mismatch. Confirm that you selected the correct algorithm and the expected digest for the exact version, operating system, and download format. Download the file again from the official source and repeat the check. If the mismatch persists, contact the publisher. A mismatch proves the bytes differ, but it does not establish whether the cause is corruption, an incorrect reference, or tampering.
Can I identify a hash algorithm just by looking at the digest?
Not reliably. A 64-character hexadecimal string is consistent with SHA-256, but other algorithms or output formats can have the same length. Check the publisherβs documentation or the toolβs algorithm setting instead of inferring the algorithm from appearance alone. A meaningful comparison requires using the same algorithm for both values.
Why do websites reset forgotten passwords instead of recovering them?
A properly designed password system stores a password-derived verifier rather than a recoverable copy of your password. It can check a submitted password, but it has no decryption step for retrieving the original. A password-reset flow lets you choose a new password after verifying your authorization. Attackers may still guess weak passwords if verifiers are stolen, which is why salts and costly password-hashing schemes matter.
How can I practice applying hashing concepts for CompTIA Security+?
Start by calculating a fileβs SHA-256 digest, editing the file, and checking it again. Then work through scenarios that ask you to choose between hashing, encryption, HMAC, and digital signatures. If you want structured practice beyond these exercises, Pluralsight is an optional next step with guided security labs, feedback, assessments, and certification practice resources to help you identify gaps and focus your study.
Affiliate link β I may earn a commission at no additional cost to you.
Jay's Recommendation
Turn understanding into hands-on confidence
You've built the foundations. Pluralsight adds opportunities to practice in guided security labs, get feedback, and check your knowledge with assessments and practice exams, so your next step is more than another video.
π Put concepts to workBuild practical skills with guided security labs and feedback.
π―Find your weak spotsUse assessments to focus on what needs more work.
πCheck your understandingUse practice exams to guide your certification preparation.
π§Give study sessions directionOrganize further learning with curated paths and progress tracking.