File Integrity

SHA-1 vs SHA-256 vs SHA-512: Which Hash Algorithm Should You Use?

8 min read
By
SHA-1 vs SHA-256 vs SHA-512: Which Hash Algorithm Should You Use?

Photo by Pexels

## Three Algorithms, One Purpose, Very Different Security

You need to verify a file. You see three options: SHA-1, SHA-256, SHA-512. Which one do you pick?

Short answer: SHA-256. Almost always.

Long answer: it depends on what you're doing, but the defaults have shifted hard. Let's break down each algorithm, what it's good for, and when you'd choose one over the others.

SHA-1: The Retired Workhorse

SHA-1 was the standard for years. Git still uses it internally. Plenty of older systems still publish SHA-1 checksums. But the algorithm is broken.

In 2017, Google and CWI Amsterdam demonstrated the SHAttered attack — the first practical SHA-1 collision. Two different PDF files with the same SHA-1 hash. Since then, browsers stopped accepting SHA-1 certificates, and the security community moved on.

A SHA-1 hash is 40 hex characters. Here's the SHA-1 of an empty file:

da39a3ee5e6b4b0d3255bfef95601890afd80709

**Use SHA-1 only when:** you're verifying against a legacy system that only publishes SHA-1 checksums, and you're checking for accidental corruption, not intentional tampering. Even then, prefer SHA-256 if it's available.

You can still check SHA-1 hashes online when you need to, but don't choose it for new work.

SHA-256: The Current Standard

SHA-256 is part of the SHA-2 family. It produces a 256-bit hash, rendered as 64 hex characters. No practical collision attacks exist. It's the default for TLS certificates, software signing, file verification, and blockchain networks.

The SHA-256 of an empty file:

e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

**Speed:** on a modern CPU, SHA-256 processes about 500 MB/s. For most files, that's instant. For a 50 GB backup, it takes about 100 seconds. Acceptable.

**Use SHA-256 when:** you're verifying software downloads, checking file integrity for backups, publishing checksums for a release, or doing anything where security matters and you don't have a specific reason to pick something else.

SHA-512: The Heavyweight

SHA-512 produces a 512-bit hash — 128 hex characters. It's part of the same SHA-2 family as SHA-256, just with larger internal state and output.

The SHA-512 of an empty file:

cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e

Here's the surprise: on 64-bit processors, SHA-512 is actually **faster** than SHA-256. It processes 64-bit words natively, while SHA-256 works with 32-bit words. On a 64-bit CPU, SHA-512 can hit 800 MB/s or more.

**Use SHA-512 when:** you're on a 64-bit system, you want maximum security margin, and you're hashing large files where the speed advantage matters. Some security-conscious projects publish both SHA-256 and SHA-512 checksums.

**Don't use SHA-512 when:** you need short hashes (they're 128 characters, which is unwieldy), or you're on a 32-bit system where it's slower than SHA-256.

Side-by-Side Comparison

| Algorithm | Hash Length | Collision Status | Speed (64-bit) | Best For | |----------|------------|-----------------|-----------------|----------| | SHA-1 | 40 chars | Broken (2017) | ~700 MB/s | Legacy only | | SHA-256 | 64 chars | Secure | ~500 MB/s | General use | | SHA-512 | 128 chars | Secure | ~800 MB/s | Large files, 64-bit |

What About SHA-3 and BLAKE3?

SHA-3 is a different family entirely — based on Keccak sponge construction. It's standardized and secure but less widely supported in tooling. You won't find sha3sum pre-installed on most systems.

BLAKE3 is the speed champion. It can hit 4+ GB/s on modern hardware thanks to parallelism. But it's newer, less standardized, and not as widely available. For now, SHA-256 remains the practical default.

Practical Advice

If you're publishing checksums for a software release, publish SHA-256. Maybe also SHA-512 if you're security-focused. Skip SHA-1.

If you're verifying a download and the publisher offers multiple options, use SHA-256 at minimum. If only SHA-1 is available, it's better than nothing for detecting accidental corruption, but you can't fully trust it against intentional tampering.

If you want to check any of these without installing tools, use a browser-based hash checker that supports all three algorithms.

The Verdict

For 95% of use cases: **SHA-256**. It's secure, widely supported, fast enough, and produces manageable 64-character hashes. Use SHA-512 when you're on 64-bit hardware and want extra margin. Use SHA-1 only when you have no other choice. And if you want to dive deeper into how hashing compares to encryption, read our hashing vs encryption explainer.,

Frequently Asked Questions

Is SHA-512 more secure than SHA-256?

SHA-512 provides a larger security margin with its 512-bit output, and on 64-bit processors it's actually faster than SHA-256. Both are currently secure with no known practical attacks. SHA-256 is more widely used and supported.

Is SHA-1 still safe to use?

SHA-1 is broken for collision resistance. A practical collision was demonstrated in 2017. It should only be used for legacy compatibility or detecting accidental corruption, never for security-critical verification.

Which hash algorithm should I use for file verification?

SHA-256 is the recommended default for file verification. It's secure, widely supported, and fast enough for most use cases. Use SHA-512 on 64-bit systems if you want extra security margin.

Try NovelCrypt Tools

Experience military-grade encryption for your sensitive data. Create self-destructing messages, encrypt files, or explore our experimental lab tools.

Explore NovelCrypt