Web Security
SHA-256 vs SHA-512 vs MD5: Which Hash Should You Use?
Compare SHA-256, SHA-512, and MD5 for integrity checks, legacy compatibility, fingerprints, and password storage while avoiding common hashing mistakes.
In this article
SHA-256 vs SHA-512 vs MD5: Which Hash Should You Use?
Developers frequently encounter MD5, SHA-256, and SHA-512 when verifying downloads, generating content fingerprints, comparing files, or integrating older systems.
They all produce deterministic digests, but they should not be treated as equally suitable for security-sensitive work.
What a cryptographic hash does
A hash function accepts input of arbitrary length and returns a fixed-size digest.
Useful properties include:
- the same input produces the same output;
- a small input change produces a very different digest;
- the original input is not meant to be recoverable from the digest;
- strong cryptographic hashes are designed to resist practical collision attacks.
Use the SHA-256 Generator or SHA-512 Generator for browser-local testing.
SHA-256
SHA-256 produces a 256-bit digest, commonly represented as 64 hexadecimal characters.
It is widely used for:
- integrity checks;
- content fingerprints;
- signed-system components;
- package and artifact verification;
- cache and content-addressing workflows.
For new general integrity workflows, SHA-256 is a common and practical choice.
SHA-512
SHA-512 produces a 512-bit digest, commonly represented as 128 hexadecimal characters.
It belongs to the SHA-2 family alongside SHA-256.
Use the SHA-512 Generator when a protocol, existing system, or compatibility requirement calls for SHA-512.
Do not assume a longer hexadecimal result automatically makes every application “twice as secure.” Security depends on the actual use case and construction.
MD5
MD5 produces a 128-bit digest and remains common in legacy checksums and old integrations.
However, MD5 has known collision weaknesses and should not be chosen for new security-sensitive collision-resistance requirements.
Duck Cloud's MD5 Generator is therefore best treated as a compatibility utility, not a recommendation to build new security systems around MD5.
Hashing is not encryption
A hash is not intended to be decrypted.
Encryption is used when authorized users must recover the original plaintext. Hashing is used when you need a deterministic digest.
Do not call a SHA-256 value “encrypted data.” That creates confusion about what security property is actually present.
Do not hash passwords directly with SHA-256
Fast hashes are designed to be fast. That is useful for integrity checks but dangerous for password storage because attackers can test large numbers of password guesses quickly.
Password databases should use dedicated password hashing algorithms designed to be expensive to guess, such as Argon2 or scrypt, with unique salts and appropriate cost parameters.
The Password Generator can help create strong random passwords, while the Password Strength Checker can provide a local estimate. Neither replaces correct server-side password storage.
Hashes and file integrity
A typical verification workflow is:
- obtain the trusted expected digest through a trusted channel;
- calculate the digest of the downloaded file;
- compare the two exact values;
- investigate any mismatch.
A matching digest can show that the bytes match the expected fingerprint. The trustworthiness of that check still depends on where the expected digest came from.
Hashes as identifiers
Hashes are also useful for identifying content. If two inputs produce different digests, the content differs.
Systems use hashes for:
- build artifacts;
- cache keys;
- deduplication;
- content-addressed storage;
- change detection.
Do not automatically expose hashes as authorization secrets. A deterministic identifier and an access credential solve different problems.
Which should you choose?
Choose SHA-256 for many new general integrity and fingerprinting workflows.
Choose SHA-512 when the protocol or system specifies it or when it fits an established design.
Use MD5 only when compatibility with an existing non-security workflow requires it, and clearly document that limitation.
Use a dedicated password hashing algorithm for passwords.
Hashing checklist
- Know whether you need integrity, confidentiality, authentication, or password protection.
- Do not substitute hashing for encryption.
- Avoid MD5 for new security-sensitive designs.
- Do not store passwords as plain SHA-256 or SHA-512 digests.
- Compare hashes exactly.
- Protect the trusted reference digest in integrity workflows.
- Use maintained cryptographic libraries rather than implementing primitives yourself.
The right hash depends on the job. Start by defining the security property you need, then select an algorithm and construction designed for that purpose.