FormatterHQ

SHA-2 Hash Generator

Compute any SHA-2 hash — SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224 or SHA-512/256 — for text or files, and switch variants with one click.

Loading tool…
Ready.

How to use the SHA-2 Hash Generator

  1. Type or paste text into the input box, or switch the source to File and choose a file — it is hashed locally, never uploaded.
  2. Set Variant; the main result at the top updates as soon as you change it.
  3. Read the main hash at the top — the table below shows the same input under every other common algorithm. Tick Uppercase hex if you need capitals.
  4. To verify a value, paste it into Compare with an expected hash — the tool reports a match, or which algorithm it matches instead. Copy any row with its Copy button.

SHA-2 hash generator: the whole family

SHA-2 is a family of six hash functions defined in FIPS 180-4. They share a common design but differ in word size, number of rounds and output length. This SHA-2 hash generator lets you pick any variant from a single menu, so you can compare outputs or match whatever a specification or API asks for.

The variants compared

All digests below are of the standard test input abc:

VariantOutputDigest of “abc” (start)
SHA-224224 bits23097d223405d8228642a477…
SHA-256256 bitsba7816bf8f01cfea414140de…
SHA-384384 bitscb00753f45a35e8bb5a03d69…
SHA-512512 bitsddaf35a193617abacc417349…
SHA-512/224224 bits4634270f707b6a54daae7530…
SHA-512/256256 bits53048e2681941ef99b2e29b7…

abc is the example message used in the FIPS 180 standard, so these values double as test vectors. The Variant menu switches between the six SHA-2 members, while the table below the main result also lists hashes from other families for the same input.

Two engines, six outputs

  • SHA-256 engine — 32-bit words, 64 rounds, 512-bit blocks. SHA-224 is this engine with different initial values and a truncated output.
  • SHA-512 engine — 64-bit words, 80 rounds, 1024-bit blocks. SHA-384, SHA-512/224 and SHA-512/256 each use their own initial values and truncate the output.

Because each truncated variant starts from different initial values, you cannot derive one from another by cutting characters off a longer hash.

Which variant should you use?

NeedGood choice
General purpose, maximum compatibilitySHA-256
Subresource Integrity, TLS with P-384SHA-384
Largest output, fast on 64-bit CPUsSHA-512
256-bit output, length-extension resistantSHA-512/256
Specification requires 224 bitsSHA-224 or SHA-512/224

Getting the same SHA-2 hash on the command line

The FIPS test value for abc only appears if exactly those three bytes are hashed. The most common reason for a mismatch is an invisible line break:

echo "abc" | sha256sum      # hashes "abc\n" → edeaaff3f1774ad2…  (different)
printf 'abc' | sha256sum    # hashes "abc"   → ba7816bf8f01cfea…  (matches)

Text files have the same issue: a file saved with Windows line endings (CR LF) has different bytes from the same text with Unix line endings, so the hashes differ even though the files look identical. On Windows, PowerShell's Get-FileHash -Algorithm SHA384 file.zip covers SHA-256, SHA-384 and SHA-512; the truncated SHA-512/224 and SHA-512/256 variants need OpenSSL (openssl dgst -sha512-256) or this page.

Security

All SHA-2 variants are considered secure: no practical collision or preimage attacks exist on the full functions. SHA-256 and SHA-512 (but not the truncated variants) are vulnerable to length-extension when misused as secret-prefix MACs — use HMAC for keyed hashing. And no SHA-2 function should be used on its own to store passwords, because they are all designed to be fast; use bcrypt, Argon2id or scrypt.

Verifying results

Command-line equivalents: sha224sum, sha256sum, sha384sum, sha512sum on Linux, or shasum -a 512256 file for SHA-512/256 with Perl’s shasum. Text in this tool is hashed as UTF-8, and files byte for byte. For SHA-3 alternatives, see SHA3-256. Everything runs in your browser.

Frequently asked questions

Is SHA-2 the same as SHA-256?
SHA-256 is one member of the SHA-2 family. SHA-2 also includes SHA-224, SHA-384, SHA-512, SHA-512/224 and SHA-512/256.
Which SHA-2 variant is the most secure?
All are secure. Longer outputs give larger security margins, and the truncated variants add resistance to length-extension attacks.
Can I get SHA-256 by truncating SHA-512?
No. Truncating SHA-512 gives neither SHA-256 nor SHA-512/256, because each variant uses different initial values.
Is SHA-2 safe for passwords?
Not by itself. SHA-2 is fast, so attackers can test many guesses per second. Use a slow, salted password hash such as bcrypt or Argon2id.

Last updated September 26, 2026

Related tools

SHA-224 Hash Generator Generate the SHA-224 hash of any text or file online. Instant 224-bit digest in hex, computed in your browser. SHA-256 Hash Generator Generate the SHA-256 hash of any text or file online. Instant 256-bit digest in hex, computed in your browser. SHA3-224 Hash Generator Generate the SHA3-224 hash of any text or file online. Instant 224-bit digest in hex, computed in your browser. SHA3-256 Hash Generator Generate the SHA3-256 hash of any text or file online. Instant 256-bit digest in hex, computed in your browser. SHA3-384 Hash Generator Generate the SHA3-384 hash of any text or file online. Instant 384-bit digest in hex, computed in your browser. SHA3-512 Hash Generator Generate the SHA3-512 hash of any text or file online. Instant 512-bit digest in hex, computed in your browser. SHA-384 Hash Generator Generate the SHA-384 hash of any text or file online. Instant 384-bit digest in hex, computed in your browser. SHA-512/224 Hash Generator Generate the SHA-512/224 hash of any text or file online. Instant 224-bit digest in hex, computed in your browser. SHA-512/256 Hash Generator Generate the SHA-512/256 hash of any text or file online. Instant 256-bit digest in hex, computed in your browser. SHA-512 Hash Generator Generate the SHA-512 hash of any text or file online. Instant 512-bit digest in hex, computed in your browser. SHAKE-128 Hash Generator Generate SHAKE-128 extendable-output (XOF) hashes of any length from text or files. SHAKE-256 Hash Generator Generate SHAKE-256 extendable-output (XOF) hashes of any length from text or files.