Comparison 5 min read

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

SHA-1, SHA-256, SHA-384 and SHA-512 compared: output length, security status and speed, plus which one to pick for checksums, signatures, APIs and passwords.

sha1 vs sha256sha256 vs sha512which hash algorithm to useis sha1 still securesha-2 family explainedsha384 vs sha256

The short answer

Use SHA-256 unless you have a specific reason not to. It is the default for file checksums, TLS certificates, API request signing and most software today. SHA-512 is equally safe and can be faster on 64-bit machines, but its output is twice as long. SHA-1 should not be used for anything security-related: NIST has told users to move to SHA-2 or SHA-3 and will stop using SHA-1 in its remaining specified protocols by 31 December 2030. You can compare all of them side by side with the free Hash Generator, which shows MD5, SHA-1, SHA-256, SHA-384 and SHA-512 for the same text at once.

The quick comparison

AlgorithmOutput sizeHex lengthStatus
MD5128 bits32 charactersBroken for security; checksums only
SHA-1160 bits40 charactersDeprecated; practical collisions exist
SHA-256256 bits64 charactersRecommended default
SHA-384384 bits96 charactersSecure; SHA-512 shortened
SHA-512512 bits128 charactersSecure; longer output

SHA-256, SHA-384 and SHA-512 all belong to the SHA-2 family. They share the same design, so "SHA-2" in a requirement usually means any of them, with SHA-256 the most common choice.

See the difference yourself

Here are the real hashes of the five-letter word hello (lowercase, no space or line break):

  • MD5: 5d41402abc4b2a76b9719d911017c592
  • SHA-1: aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
  • SHA-256: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

The SHA-512 result for the same word is 128 hex characters long. Change one letter, such as Hello with a capital H, and the SHA-256 becomes 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969, completely different. That is the property that makes hashes useful for spotting changes.

To reproduce this:

  • Open the Hash Generator and stay on Hash text.
  • Type hello with no trailing space or new line.
  • Click Generate Hashes. All five results appear, each with a Copy button.
  • If your result differs from the one above, you almost certainly have an extra space, a line break or a different letter case. The guide on why the same text gives a different hash lists the usual causes.

    Why SHA-1 is no longer safe

    A hash is only secure if nobody can find two different inputs with the same output (a collision). Researchers demonstrated practical SHA-1 collisions years ago, and NIST's December 2022 announcement says collision attacks have weakened SHA-1 and that attacks in other uses have grown more severe. NIST's advice is direct: anyone relying on SHA-1 for security should migrate to SHA-2 or SHA-3 as soon as possible, and SHA-1 will be phased out of its remaining specified protocols by the end of 2030.

    That does not mean every SHA-1 value you see is a problem. Git historically identifies commits with SHA-1, and some old download pages still publish SHA-1 checksums. Using SHA-1 to notice accidental corruption is different from using it to prove a file has not been deliberately tampered with. For anything where an attacker might be involved, such as signatures, certificates or verifying software downloads, use SHA-256 or stronger.

    SHA-256 vs SHA-512

    Both are considered secure today. The practical differences are:

    • Length. A SHA-512 hex digest is 128 characters, twice as long as SHA-256. That matters for database columns, URLs and anything a human has to compare by eye.
    • Speed. SHA-512 works on 64-bit words, so on many 64-bit processors it hashes large files at a similar or faster speed than SHA-256. On 32-bit and some small embedded chips it is slower. For a typical document or download, either one finishes almost instantly.
    • Compatibility. SHA-256 is the more common default. If a website, API or tool asks for "SHA-2" without details, SHA-256 is the safe assumption.

    SHA-384 is SHA-512 with a different starting value and a shorter output. You will meet it in some TLS cipher suites and government profiles. Use it when a specification asks for it.

    Which hash for which job

    TaskUseNotes
    Verify a downloaded fileWhatever the publisher lists, ideally SHA-256Compare your result with the published value
    Detect duplicate filesSHA-256MD5 also works if no one is trying to fool you
    API request signingHMAC with SHA-256Follow the API's documentation exactly
    Digital signatures and certificatesSHA-256 or strongerNever SHA-1 or MD5
    Storing passwordsNone of these aloneUse bcrypt, scrypt or Argon2, which are slow on purpose
    Cache keys and ETagsSHA-256 or MD5Security is not the goal here

    A note on passwords

    SHA-256 is designed to be fast, which is exactly what you do not want for stored passwords: an attacker who steals the database can try billions of guesses quickly. Password storage needs a deliberately slow, salted algorithm such as bcrypt or Argon2. The Hash Generator is not a password-storage tool.

    Hashing a file

    The Hash Generator also has a Hash file tab. Drop a file on it and it calculates the SHA-1, SHA-256, SHA-384 and SHA-512 of the file's contents using your browser's built-in Web Crypto functions, so the file is not uploaded. For the complete checksum workflow on Windows, Mac and Linux, follow how to verify a file checksum.

    Use the SHA results for file checks. In file mode the MD5 row is currently calculated from the file name rather than the file contents, so do not compare it with a published MD5 checksum.

    Summary

    • Pick SHA-256 by default.
    • Pick SHA-512 or SHA-384 when a system or specification asks for it.
    • Use SHA-1 and MD5 only for non-security checks, or to match an old checksum that is published that way.
    • Use a password-hashing algorithm, not plain SHA, for passwords.

    For background on what MD5 is still good for, see is MD5 secure.

    Frequently asked questions

    Is SHA-1 still secure?

    No, not for security uses. Practical collision attacks exist, and NIST recommends moving to SHA-2 or SHA-3. NIST will stop using SHA-1 in its remaining specified protocols by 31 December 2030.

    Is SHA-512 more secure than SHA-256?

    Both are considered secure today. SHA-512 has a longer output and a larger security margin, but SHA-256 is already far beyond practical attack. Choose SHA-256 by default and SHA-512 when a system asks for it.

    How long is a SHA-256 hash?

    SHA-256 produces 256 bits, shown as 64 hexadecimal characters. SHA-1 is 40 characters, SHA-384 is 96 and SHA-512 is 128.

    Can I use SHA-256 to store passwords?

    Not on its own. SHA-256 is fast, which helps attackers guess passwords. Use a slow, salted password-hashing algorithm such as bcrypt, scrypt or Argon2.

    Try this tool on Lazyblink

    Put this guide into practice with our free online tool — no signup required.

    Open tool