Cybersecurity glossary
What is Secure Hash Algorithm 2 (SHA-2)?
Learn what SHA-2 is, how SHA-256 and SHA-512 differ, where hash functions are safe to use, and why hashing alone is not encryption or password storage.
Definition
Secure Hash Algorithm 2 (SHA-2) is a family of cryptographic hash functions—including SHA-256, SHA-384, and SHA-512—that map arbitrary input to a fixed-length digest used for integrity checks, digital signatures, and keyed constructions such as HMAC.
Why SHA-2 underpins integrity everywhere
Software updates, TLS handshakes, Git objects, JWTs, and certificate signatures all depend on cryptographic digests. SHA-2—especially SHA-256—became the default hash family after SHA-1’s collision weaknesses made continued use unacceptable for signatures.
What SHA-2 provides
Fixed-length digest
SHA-256 yields 32 bytes; SHA-512 yields 64 bytes regardless of input size.
Collision resistance goals
Finding two inputs with the same digest should be infeasible for secure members.
Preimage resistance
Recovering an input from a digest should be infeasible.
Building block role
Used inside HMAC, digital signatures, KDFs, and transcript hashes.
How SHA-2 is typically used for integrity
Select a SHA-2 member
Choose SHA-256/384/512 according to protocol or policy.
Hash the canonical bytes
Feed the exact message encoding into the hash function.
Publish or sign the digest
Pair with a signature, HMAC, or trusted channel—digest alone is not authenticity.
Recompute on receipt
Verifiers hash their copy and compare or validate the signature over the digest.
Reject on mismatch
Any difference indicates corruption or tampering.
SHA-2 members at a glance
Pick the variant your ecosystem standardizes; do not invent truncated custom aliases casually.
| Variant | Digest bits | Common use |
|---|---|---|
| SHA-256 | 256 | TLS, JWT, general integrity, many signatures |
| SHA-384 | 384 | Some TLS 1.3 cipher suites and higher-margin profiles |
| SHA-512 | 512 | High-assurance hashing and 64-bit optimized platforms |
| SHA-224 | 224 | Less common; use only when a profile requires it |
Operational checklist
- Replace SHA-1 in signatures, certificates, and security tokens.
- Do not use raw SHA-2 as a password hash.
- Prefer HMAC-SHA-256 or AEAD when attackers can modify data.
- Use library APIs that implement FIPS-approved SHA-2 correctly.
- Hash canonical encodings to avoid parser differentials.
- When truncating digests, follow a standard—do not invent short fingerprints for security decisions.
- Keep software update pipelines on SHA-2 or stronger with signatures.
- Document which SHA-2 variant each protocol endpoint requires.
Hashing is not a security Swiss army knife
Teams sometimes “secure” API payloads by attaching an unkeyed SHA-256 of the body. An attacker who can modify the body can also recompute the digest. Integrity against adversaries needs a secret key (HMAC/AEAD) or a private signature key.
The practical takeaway
SHA-2 is the workhorse cryptographic hash family behind modern integrity and signatures. Use SHA-256/384/512 as protocols require, never as a password hash, and combine digests with keys or signatures whenever attackers are in scope.
Related security terms
Secure Hash Algorithm 3 (SHA-3)
A later NIST hash family based on the Keccak sponge construction.
HMAC
A keyed MAC commonly built with SHA-2 hash functions.
Digital signatures and certificates
X.509 certificates rely on hash digests inside signature algorithms.
Password hashing
Why general-purpose hashes like SHA-256 are not enough for password storage.
TLS 1.3
Handshake transcripts and key schedules use hash functions such as SHA-256/SHA-384.
Frequently asked questions
What is SHA-2 in simple terms?
SHA-2 is a set of algorithms that produce a fixed fingerprint of data. Changing even one bit of input should produce a completely different digest.
Is SHA-256 part of SHA-2?
Yes. SHA-256, SHA-224, SHA-384, SHA-512, and the SHA-512/n variants are members of the SHA-2 family.
Is SHA-2 encryption?
No. Hashing is one-way. You cannot decrypt a digest to recover arbitrary input.
Can I store passwords with SHA-256?
Not by itself. Use a password hashing function such as Argon2id, scrypt, or bcrypt. Fast hashes enable rapid offline guessing.
Is SHA-1 the same as SHA-2?
No. SHA-1 is an older, broken-for-collision-resistance hash and must not be used for signatures or security-sensitive integrity in modern systems.
When should I choose SHA-512 over SHA-256?
Follow protocol requirements first. On 64-bit platforms SHA-512 can be fast; some profiles prefer SHA-384/SHA-512 for higher security margins.
Does SHA-2 provide authenticity alone?
No. Unkeyed digests detect accidental changes but not attackers who can recompute hashes. Use HMAC, signatures, or AEAD for adversarial integrity.
References
Explore authoritative guidance and frameworks related to secure hash algorithm 2 (sha-2).
Explore every security definition
Return to the glossary to search by term, alias, starting letter, or security category.