π Master your Security+ skills with Pluralsight here: Pluralsight
Youβll learn how SHA-256 vs MD5 compares, why collision resistance matters, and why a matching checksum doesnβt guarantee a safe file. Build your CompTIA Security+ foundation and avoid common hashing mistakes when checking data integrity or storing passwords.
Chapters: 0:00 Intro 0:15 What does a cryptographic hash actually do? 0:54 What makes a hash algorithm secure? 1:46 Why is MD5 insecure compared with SHA-256? 3:19 Does a matching SHA-256 checksum mean a file is safe? 4:05 Should you use SHA-256 for password storage? 4:50 Outro
Affiliate notice: Some links may earn a commission. Thanks for your support.
Hash security requires preimage, second-preimage, and collision resistance. Finding two colliding inputs does not automatically let attackers replace an arbitrary existing file.
Digest length alone does not guarantee security. SHA-256 offers roughly 128-bit collision strength, while MD5βs design flaws undermine even its idealized strength.
A matching checksum does not prove a file is safe or authentic. Obtain the reference digest from a trustworthy, authenticated source and protect stored integrity baselines from tampering.
Use HMAC or digital signatures when authenticity matters. HMAC authenticates data among shared-secret holders; signatures require a trusted public verification key.
Neither plain SHA-256 nor MD5 is suitable for password storage. Follow OWASP guidance: use a dedicated scheme such as Argon2id, with unique salts and appropriately configured costs.
π Turn hashing concepts into hands-on skills with Pluralsight, an optional next step offering guided security labs, feedback, assessments, and certification practice.
SHA-256 and MD5 both turn data into a fixed-length digest, but they are not interchangeable security tools. SHA-256 is suitable for modern cryptographic integrity applications; MD5 is not suitable when an attacker could exploit collisions.
The difference goes beyond digest length. A secure hash must resist specific attacks, and the system using it must protect the reference value being checked. Even a perfectly matching SHA-256 checksum does not prove that a file is safe.
Understanding SHA-256 vs MD5 starts with what hashing actually does, and what it cannot do.
What Does a Cryptographic Hash Do?
A cryptographic hash function takes input data and produces a fixed-length output called a , , or .
Some links may earn a commission. Thanks for your support.
Watch in the video playerOpen the dedicated player for this course.
hash value
digest
message digest
For a given algorithm:
Identical input bytes always produce the same digest.
The output length stays the same regardless of input size.
A small input change should produce a substantially different-looking digest.
That last behavior is called the avalanche effect. Changing one character in a document should change its digest dramatically. However, scrambled-looking output is not proof of security: MD5 exhibits avalanche behavior despite its known weaknesses.
Hashing Is Not Encryption
Encryption protects confidentiality. Someone with the appropriate key can decrypt ciphertext and recover the original data.
Hashing has no corresponding decryption operation. Its main role is to support integrity: checking whether data matches an expected state.
A hexadecimal hash is also not encrypted content. Hexadecimal is simply a way of representing the digestβs bytes.
Hashes Represent Bytes, Not Appearances
File-hashing tools ordinarily process file contents, not filenames. Renaming a file without changing its contents leaves its content hash unchanged.
By contrast, adding a newline, changing character encoding, or modifying embedded metadata changes the input bytes and ordinarily changes the digest. Two documents can look identical on screen without being byte-for-byte identical.
SHA-256 vs MD5: Side-by-Side Comparison
Property
MD5
SHA-256
Full name
Message-Digest Algorithm 5
Secure Hash Algorithm with a 256-bit output
Algorithm family
MD family
SHA-2
Digest length
128 bits, or 16 bytes
256 bits, or 32 bytes
Hexadecimal length
32 characters
64 characters
Collision resistance
Broken by practical attacks
No known practical collision attack
Modern attacker-resistant integrity
Not appropriate where collision resistance is required
Appropriate when used in a sound construction
Password storage by itself
Not appropriate
Not appropriate
NISTβs hash-function guidance includes SHA-256 among its approved hash algorithms. RFC 6151 explicitly rejects MD5 for uses that require collision resistance, including digital signatures.
SHA-256 belongs to SHA-2, not SHA-1. SHA-3 is a separate family; its existence does not mean SHA-256 has suffered the collision failures associated with MD5 or SHA-1.
What Makes a Hash Algorithm Secure?
Three resistance properties define the central security expectations for a cryptographic hash.
Preimage Resistance
Given a digest, finding an input that produces it should be computationally infeasible.
The attacker starts with a target hash value and tries to find matching data. This does not require recovering the original input, any input producing that digest would meet the attackerβs goal.
Second-Preimage Resistance
Given a particular input, finding a different input with the same digest should be computationally infeasible.
Imagine that an investigator has already recorded the trusted SHA-256 digest of an evidence file. An attacker wants to substitute a different file while retaining that exact digest. This is a second-preimage problem.
Collision Resistance
Finding any two different inputs with the same digest should be computationally infeasible.
Here, the attacker can choose both inputs. That flexibility matters: preparing a harmless-looking document and a malicious document together is a different problem from replacing an arbitrary existing file.
Property
What the attacker starts with
What the attacker wants
Preimage resistance
A target digest
Any input that produces it
Second-preimage resistance
A particular input
A different input with its digest
Collision resistance
Freedom to choose both inputs
Two different inputs with the same digest
These properties are related, but they are not interchangeable. A practical collision attack does not automatically let an attacker replace any existing file or recover an unknown original message.
Why Collisions Must Exist
A fixed-length digest has a limited number of possible values, while the space of possible inputs is much larger. Multiple inputs must therefore share outputs.
Security does not mean collisions are mathematically impossible. It means finding useful collisions is computationally infeasible.
Why a Longer Digest Helps, but Does Not Guarantee Security
The lower collision bound comes from the birthday effect: looking for a match among many pairs is easier than matching one predetermined value.
This means:
An ideal 128-bit hash would provide about 64-bit collision strength.
SHA-256 provides about 128-bit collision strength, not 256-bit collision strength.
MD5 falls short of its idealized collision strength because attackers can exploit weaknesses in its design.
These numbers describe approximate work factors, not fixed cracking times.
Digest length establishes a potential security ceiling. Algorithm design, public cryptanalysis, and correct implementation determine whether a system approaches that ceiling.
Why Is MD5 Considered Insecure?
MD5 has practical collision attacks. Attackers can deliberately construct different inputs that produce the same MD5 digest.
A notable real-world example involved researchers creating a rogue certificate-authority certificate using MD5 collisions. Carefully constructed certificates allowed a legitimate signature to validate a different, dangerous certificate. This demonstrated why collision resistance matters in actual public-key infrastructure, not just in theoretical examples.
The lesson is application-specific:
Do not choose MD5 for new digital-signature designs.
Do not rely on it for attacker-resistant file integrity where collisions matter.
Do not assume an MD5 collision attack means every existing MD5-tagged file can be replaced at will.
MD5 can still appear in accidental-corruption checks or legacy malware identifiers. Those uses do not establish that it is safe for cryptographic trust. When choosing a modern digest for security-sensitive integrity checks, use SHA-256 rather than MD5.
Does a Matching SHA-256 Checksum Mean a File Is Safe?
No. A matching checksum means the file matches the reference digest you checked.
That reference might describe a legitimate file, or a malicious one.
Suppose an attacker replaces a download and the checksum displayed beside it. You calculate SHA-256, compare the values, and get a match. The attacker has not broken SHA-256. They have simply supplied a consistent file-and-digest pair.
This is why the referenceβs origin matters.
Protect the Reference, Not Just the File
A useful integrity-checking process requires:
An appropriate hash algorithm.
A trustworthy reference digest.
Protection against unauthorized changes to that reference.
A comparison of the correct file using the correct algorithm.
For file integrity monitoring, the reference is often called a baseline. If attackers can replace both a monitored file and its stored baseline, ordinary hash comparison may not reveal the tampering.
A changed digest also does not automatically prove malicious activity. Authorized updates change files too; monitoring must distinguish expected changes from suspicious ones.
Use HMAC or Digital Signatures for Authenticated Integrity
A plain digest does not authenticate its publisher. Established constructions add that protection:
RFC 2104 defines HMAC. It is an established construction, not simply a secret concatenated with data and passed through a hash.
A file can also match an authentic publisherβs digest and still contain unsafe software. Integrity checking is not malware analysis.
How to Check a Fileβs SHA-256 Hash
Before comparing values, obtain the expected SHA-256 digest from a trustworthy, authenticated source.
Compare the returned hash with the published SHA-256 value. PowerShellβs Get-FileHash defaults to SHA-256, but specifying the algorithm makes the check explicit.
A successful manifest check means the listed file digests match. It does not authenticate the manifest itself.
If the hash does not match the trusted reference, the file is not byte-for-byte consistent with that reference. Investigate the discrepancy rather than treating the file as verified.
Why SHA-256 Alone Is Not Suitable for Password Storage
SHA-256 is fast. That is useful when hashing large files, but undesirable when protecting human-chosen passwords against offline guessing.
An attacker with stolen password hashes can:
Choose a candidate password.
Hash it using the relevant procedure.
Compare the result with a stolen verifier.
Repeat with more guesses.
This is guessing, not hash decryption. SHA-256 can remain cryptographically secure while weak passwords are guessed successfully.
Unique salts: Nonsecret per-password values that prevent shared precomputed results.
Computational cost: Makes each password guess more expensive.
Memory hardness: Adds memory requirements to increase attack cost.
Optional pepper: An additional secret stored separately from the password database.
A salt does not make a single SHA-256 operation sufficiently expensive for password storage. Likewise, PBKDF2-HMAC-SHA-256 is a separate password-based construction, not another name for hashing a password once with SHA-256.
Applying Hashing Concepts in Cybersecurity Work
For Security+ learners and early-career practitioners, the important skill is choosing the right mechanism for the job.
For log integrity, real systems often combine these mechanisms. AWS CloudTrail, for example, uses SHA-256 hashes, digital signatures, and linked digest files. Hashing is one component of the evidence, not the entire trust model.
The practical rule is to match the construction to the threat: SHA-256 can support strong integrity checks, but it cannot independently authenticate a publisher, make a download harmless, or protect weak passwords from rapid guessing.
Build Hands-On Hashing and Security Skills
Understanding the terminology is a strong foundation. Applying it means practicing file checks, recognizing untrusted references, and deciding when a task requires hashing, authentication, or password-specific protection.
Pluralsight offers an optional next step with guided security labs, feedback, assessments, and certification practice resources. Use that practice to identify gaps and give your next study session a clear focus.
Affiliate notice: Some links may earn a commission. Thanks for your support.
What Is Password Salting, and How Does It Work? (Explained Clearly)
Next
FAQ
Quick answers to the questions people usually ask about this topic.
How do I check a fileβs SHA-256 checksum on macOS?
Open Terminal and run shasum -a 256 "/path/to/download.iso", replacing the example path with your fileβs location. Compare the resulting digest with the SHA-256 value from a trustworthy, authenticated source. A match confirms consistency with that reference, not that the file is harmless.
What should I do if a downloaded fileβs SHA-256 checksum does not match?
Do not treat the file as verified. Confirm that the reference is for the exact version and platform you downloaded, and that you selected SHA-256 rather than MD5 or another algorithm. Try downloading the file again from the official source. If the mismatch persists, contact the publisher before using it; corruption, a wrong version, or tampering could explain the difference.
Should I verify both MD5 and SHA-256 when a download lists both?
For a security-sensitive check, prioritize SHA-256 and a trustworthy reference. Checking MD5 as well does not fix an untrusted checksum source or authenticate the publisher. If the publisher provides a digital signature, verifying it with a trusted public key can add publisher authentication that plain checksums lack.
Can I convert an existing MD5 checksum into a secure SHA-256 checksum?
No. To obtain a fileβs SHA-256 checksum, you must hash the original file bytes using SHA-256. Applying SHA-256 to an MD5 digest only hashes that digest: files sharing the same MD5 value would still produce the same result through this process. When migrating integrity records, calculate new SHA-256 baselines from files whose authenticity and integrity you have established.
Is MD5βs faster speed a good reason to use it instead of SHA-256?
Not when attacker-resistant integrity is required. Performance depends on hardware and implementation, but speed does not compensate for MD5βs broken collision resistance. Choose an appropriate secure algorithm first, then measure performance in your environment. NISTβs hash-function guidance includes SHA-256 among its approved algorithms.
Can you tell whether a hash is MD5 or SHA-256 just by looking at it?
Length is a clue, not proof. A complete hexadecimal MD5 digest has 32 characters, while a complete hexadecimal SHA-256 digest has 64. Other algorithms, encodings, or truncated values can make identification ambiguous. Check the tool settings or publisherβs algorithm label before comparing checksums. Uppercase versus lowercase hexadecimal letters does not change the digest value.
How can I practice choosing between hashing, HMAC, and password hashing for Security+?
Start with small tasks: verify a file against a trusted SHA-256 reference, change its contents and compare again, then explain why message authentication needs HMAC or a digital signature and password storage needs a dedicated password-hashing scheme. For structured practice, explore Pluralsight as an optional next step, with guided security labs, feedback, assessments, and certification practice resources to help identify gaps.
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.