What Is SHA-256?
Because SHA-256 underlies TLS certificates, software package verification, and blockchain consensus, understanding what it produces is essential for anyone working with security infrastructure1. SHA-256 is a member of the SHA-2 family, published by NIST in 2001 under FIPS 180-42, and remains the de-facto standard hash function for general security use in 2026.
What is SHA-256?
Internal structure and output properties
SHA-256 processes input in 512-bit blocks through a series of 64 rounds5, each applying bitwise operations, modular addition, and message schedule functions. The algorithm maintains an internal state of eight 32-bit words, initialized to constants derived from the fractional parts of the square roots of the first eight prime numbers. Consequently, the output is deterministic and uniformly distributed across the 2^256 possible values - no input produces a predictably "higher" or "lower" hash. The avalanche effect means a one-bit change in input causes approximately half the output bits to change.
Why fixed length matters
A fixed 256-bit output makes SHA-256 easy to store, compare, and index. Whether the input is a short password candidate or a multi-gigabyte disk image, the digest remains 32 bytes before encoding. That predictable length is why SHA-256 fits cleanly into database columns, API schemas, logs, and content-addressed storage systems. Variable-length outputs would complicate every downstream system that stores or compares hashes, because the consumer would need to know the input size to allocate the right amount of space for the digest.
You benefit from the fixed length whenever you store, compare, or index a digest, because the predictable size fits cleanly into database columns and API schemas. A 32-byte output means every downstream system can allocate the same space whether the input is a password candidate or a disk image. CapyToolkit shows SHA-256 output in your browser so you can confirm the 64-character length before copying the value into a field.
Security status and attack resistance
SHA-256 has no known practical collision, preimage, or second-preimage attacks as of 2026. Finding a collision (two inputs with the same hash) requires approximately 2^128 operations under current theoretical understanding - computationally infeasible with any foreseeable classical computing technology. Quantum computers running Grover's algorithm reduce preimage search to approximately 2^128 operations, which remains infeasible at current and projected quantum hardware capabilities. Yet researchers continue analyzing SHA-256 against future attack methods; NIST developed SHA-3 as a structural backup should weaknesses emerge in SHA-2.
What SHA-256 does not prove
A matching SHA-256 value proves the bytes match the value you compared. It does not prove the source is trustworthy, the software is safe, or the key used to create an HMAC is valid. Pair SHA-256 with trusted checksum sources, authenticated channels, or HMAC when the result affects trust decisions. Think of a hash as a fingerprint for data: it confirms the data has not changed, but it says nothing about whether the data was good or trustworthy in the first place, which is why secure systems combine hashing with signatures and authenticated delivery channels.
Common applications
SHA-256 appears in TLS certificate signatures (every HTTPS connection), Bitcoin and most cryptocurrency proof-of-work systems, software package managers (npm integrity, macOS code signing, apt), and digital signatures under RSA and ECDSA. Building on this breadth: choosing SHA-256 gives maximum compatibility across languages, libraries, and platforms. The algorithm is hardware-accelerated on modern Intel, AMD, and ARM processors via dedicated instructions (Intel SHA-NI, ARMv8 Crypto Extension), making it fast enough for high-throughput applications.
Choosing SHA-256 when interoperability matters
SHA-256 is the least surprising choice when another system must read the same digest. Most languages include it in the standard library, most checksum tools understand it, and most documentation assumes a 64-character lowercase hex string. That ecosystem support reduces integration risk compared with newer algorithms. When you are building a system that other teams or external partners will consume, choosing SHA-256 means they can verify your checksums with whatever tools they already have installed, without needing to install a specialized library or learn a new output format.
SHA-256 compared with SHA-3 and BLAKE3
SHA-3 (Keccak) was standardized by NIST in 2015 as a structural backup to SHA-2, not a direct replacement. SHA-3-256 produces the same 256-bit output as SHA-256 using a completely different internal construction called the sponge function, which shares no design elements with SHA-2's Merkle-Damgard structure. NIST developed SHA-3 to ensure that a structural weakness in SHA-2, if discovered, would not compromise the backup algorithm. Both SHA-256 and SHA-3-256 remain secure as of 2026, with no practical attacks on either.
BLAKE3, released in 2020, outperforms SHA-256 in software on modern CPUs and provides comparable security. It is not yet NIST-approved, which excludes it from FIPS 140-3 validated systems, PCI-DSS, HIPAA, and FedRAMP contexts. For developer tooling, package managers, and internal systems without compliance requirements, BLAKE3 is technically sound. SHA-256 remains the correct default for any application that may require regulatory validation.
On modern CPUs, SHA-256 runs on dedicated hardware instructions
Intel processors with the SHA-NI extension, available since Goldmont microarchitecture (2016), and ARM processors with the ARMv8 Crypto Extension execute SHA-256 on dedicated processing units rather than general-purpose arithmetic pipelines. These instructions accelerate SHA-256 to multi-gigabyte-per-second throughput on a single core, fast enough that memory access rather than computation becomes the throughput bottleneck for most file hashing workloads.
Most language runtimes use these instructions automatically when the hardware supports them. Python's hashlib delegates to OpenSSL, which detects and activates SHA-NI at startup. Node.js inherits the same behavior through its OpenSSL dependency. Java's JVM applies similar optimizations. You do not need to configure anything to benefit from hardware acceleration; the speedup is transparent at the library level.
Try in the tool
What to look for
- SHA-256 hex length 64 characters
- SHA-256 base64 length 44 characters
- SHA-2 family sizes SHA-224, SHA-256, SHA-384, SHA-512
Open the Hash Generator: MD5, SHA-1, SHA-256 & SHA-512 tool to try this yourself.
Open the tool →- 1.
"SHA-2," Wikipedia, accessed June 2026. https://en.wikipedia.org/wiki/SHA-2
- 2.
NIST, "Secure Hash Standard (SHS)," FIPS 180-4, nist.gov, August 2015. https://csrc.nist.gov/pubs/fips/180-4/upd1/final
- 3.
D. Eastlake 3rd, T. Hansen, "US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)," RFC 6234, rfc-editor.org, May 2011. https://www.rfc-editor.org/rfc/rfc6234
- 4.
NIST, "Recommendation for Applications Using Approved Hash Algorithms," SP 800-107 Rev. 1, nist.gov, August 2012. https://csrc.nist.gov/pubs/sp/800-107/r1/final
- 5.
"Grover's algorithm," Wikipedia, accessed June 2026. https://en.wikipedia.org/wiki/Grover%27s_algorithm
SHA-256 produces 256 bits of output. In hex encoding, that is 64 lowercase characters (each hex character represents 4 bits: 256 / 4 = 64). In base64 encoding, the 32-byte output encodes to 44 characters, including the two trailing = padding characters.
SHA-2 is a family of algorithms. SHA-256 is the most widely used member, producing a 256-bit digest. Other SHA-2 members include SHA-224 (224 bits), SHA-384 (384 bits), SHA-512 (512 bits), SHA-512/224, and SHA-512/256. All share the same core structure but differ in digest length and internal constants.
No. SHA-256 is a one-way function by design. There is no "decrypt" operation. The only known method to find an input for a given SHA-256 hash is brute force - trying inputs until one matches. For long, complex inputs this is computationally infeasible. For short or common inputs (passwords, short strings), lookup tables (rainbow tables) can reverse the hash if no salt was used.
The term "secure" in Secure Hash Algorithm refers to the NIST standardization under the Federal Information Processing Standard, not a claim of absolute security. SHA-256 is currently considered cryptographically secure because no practical attack exists. If a practical collision attack were found, NIST would revise the security status, as it did for SHA-1 in 2017.
SHA-256 (and the broader SHA-2 family) replaced SHA-1 as the standard. NIST deprecated SHA-1 for security applications in 2017. Certificate authorities stopped issuing SHA-1 TLS certificates the same year. SHA-3 was standardized in 2015 as a structural backup to SHA-2, not a replacement.
Yes. CapyToolkit's Hash Generator computes SHA-256 in your browser, so the text or file you enter is not uploaded to produce the digest. It is useful for checking output length, hex format, and HMAC-SHA256 examples locally.
What Is MD5?
Although MD5 produces collisions too easily for cryptographic security1, it remains pervasive in checksum files, legacy databases, and developer tooling because it is fast and universally supported. Knowing what MD5 is - and what it is not - determines when you can use it safely and when it introduces risk.
What is MD5?
RFC 1321), MD5 was widely used for file integrity and password hashing until collision attacks were demonstrated in 20043. It is now considered cryptographically broken for security-sensitive use4 but remains acceptable for non-adversarial checksum purposes.Why MD5 is cryptographically broken
A collision attack finds two different inputs that produce the same hash without any knowledge of a target input. MD5 collision attacks have been practical since 2004, when researchers from Xiaoyun Wang's group demonstrated the first full MD5 collision. The Flame malware (2012) exploited an MD5 collision in the Microsoft Terminal Server Licensing service to forge a code-signing certificate5, demonstrating that MD5 collisions are not merely academic. Consequently, MD5 cannot protect against an adversary who is motivated to forge the hash. Yet a random cosmic ray flipping a bit in a downloaded file is not an adversary - MD5 catches accidental corruption just as reliably as SHA-256.
Naming the threat model
Before choosing MD5, state whether the file can be chosen by an attacker. If the answer is no, MD5 can be a reasonable checksum for accidental corruption. If the answer is yes, choose SHA-256. The algorithm decision should follow the trust boundary, not the convenience of existing examples. Write the threat model down in a comment or design document near the hash call site, so the next developer understands why MD5 was chosen and knows the conditions under which it must be upgraded to SHA-256.
You make the right call by stating whether the file in question can be chosen by an attacker before you accept MD5 for the job. A trusted internal pipeline can use MD5 to catch accidental corruption, while any externally influenced download needs SHA-256. CapyToolkit computes MD5 locally so you can verify a legacy checksum without uploading the file, but it points you to SHA-256 for anything that affects trust.
MD5 for password storage is never acceptable
MD5 is a fast hash function, designed to process data as quickly as possible. Furthermore, MD5 with no salt means that every user with the same password gets the same hash, enabling lookup table attacks. Databases of precomputed MD5 hashes for billions of common passwords exist publicly. A database of MD5-hashed passwords is effectively a database of plaintext passwords against these lookup tables. Even salted MD5 is unacceptable for modern password storage because the speed that makes MD5 useful for checksums (hundreds of millions of operations per second on a GPU) makes it trivially brute-forceable for passwords. Use bcrypt, scrypt, or Argon2 instead.
Legitimate uses of MD5 in 2026
MD5 remains appropriate for non-security checksums: detecting accidental file corruption in a trusted pipeline, generating cache keys for content-addressed storage, computing database shard keys, and reading checksums published by legacy systems. Building on this pragmatic view: if you are processing a file through an internal pipeline with no adversarial exposure, MD5 provides fast integrity verification. The moment an adversary could influence the file content - external downloads, user uploads, supply chain artifacts - switch to SHA-256. The performance difference between MD5 and SHA-256 is negligible for most applications.
Keeping legacy MD5 fields visible
Do not hide MD5 use behind a generic checksum name. Name fields md5_checksum or legacy_checksum so future maintainers can find them during audits. A visible legacy field is easier to migrate than a generic hash column that silently controls trust decisions. When a field name says "checksum" without specifying the algorithm, a future developer might assume it is SHA-256 and build security-sensitive logic on top of it without realizing the underlying hash offers no collision resistance against a motivated attacker.
In legacy migrations, preserve existing MD5 values and add SHA-256 in parallel
In existing databases, file manifests, and package repositories, MD5 checksums from before SHA-256 became standard remain alongside the content they describe. During a migration, add a sha256_checksum column rather than replacing the md5_checksum column in place. Dual-column storage lets existing consumers continue reading MD5 values while you compute SHA-256 for new entries and backfill old ones at a pace your database handles without impacting production queries.
For CSV or JSON manifests published by legacy tooling, write a migration script that re-hashes each referenced file with SHA-256 and outputs a new manifest alongside the original. Downstream consumers with MD5-only support continue using the original; newer consumers adopt SHA-256. Document the transition timeline in the manifest schema so consumers know which version to move to.
When a third-party system requires MD5, confirm the security context first
When an external service requires MD5 for a checksum or identifier field, confirm whether the context involves adversarial exposure before accepting the requirement. Internal build pipelines, file transfer between controlled systems, and cache key generation sit outside adversarial exposure: MD5 detects accidental corruption adequately in these cases. Supply chain artifacts from external sources, user-uploaded files, and any checksum used to make a trust decision all require SHA-256.
Document any MD5 usage in code comments and track it in your technical debt registry so that the migration team can find and replace these call sites when the upstream dependency is eventually updated. When the system requiring MD5 is updated or replaced, the documented usage ensures the migration team identifies and replaces the MD5 path rather than leaving it as a silent legacy.
Planning the migration path
Record which downstream system still requires MD5, who owns it, and when it can move to SHA-256. That record turns a vague legacy exception into a manageable migration item with clear accountability. Without an owner and target date, MD5 compatibility tends to persist long after the original dependency is gone. Set a concrete deadline and add a calendar reminder for the owning team, because open-ended migration items rarely get prioritized against feature work unless someone is explicitly accountable for closing them.
Try in the tool
What to look for
- MD5 hex length 32 characters (128 bits)
- MD5 base64 length 24 characters
Open the Hash Generator: MD5, SHA-1, SHA-256 & SHA-512 tool to try this yourself.
Open the tool →- 1.
"MD5," Wikipedia, accessed June 2026. https://en.wikipedia.org/wiki/MD5
- 2.
R. Rivest, "The MD5 Message-Digest Algorithm," RFC 1321, rfc-editor.org, April 1992. https://www.rfc-editor.org/rfc/rfc1321
- 3.
X. Wang, D. Feng, X. Lai, H. Yu, "Collisions for Hash Functions MD4, MD5, HAVAL-128 and RIPEMD," eprint.iacr.org, August 2004. https://eprint.iacr.org/2004/199
- 4.
NIST, "Transitioning the Use of Cryptographic Algorithms and Key Lengths," SP 800-131A Rev. 2, nist.gov, March 2019. https://csrc.nist.gov/pubs/sp/800/131/a/r2/final
- 5.
"Flame (malware)," Wikipedia, accessed June 2026. https://en.wikipedia.org/wiki/Flame_(malware)
MD5 produces 128 bits of output: 32 lowercase hex characters, or 16 raw bytes. In base64, the 16-byte output encodes to 24 characters, including the trailing = padding.
It detects accidental corruption but not deliberate tampering. An attacker who controls the download infrastructure could craft a malicious file with the same MD5 as the legitimate one. For software from untrusted mirrors or security-critical tools, use SHA-256 instead.
Legacy compatibility. The npm registry uses SHA-512 for integrity checks, but some older tools and package manifests were built before SHA-256 became standard. Many developers continue to publish MD5 checksums alongside SHA-256 for tools that only understand MD5.
Generally no. FIPS 140-2 restricts approved hash algorithms to SHA-1 (for limited uses), SHA-256, SHA-384, and SHA-512. MD5 is not approved under FIPS 140-2 for any use. Some environments allow MD5 with an explicit non-security-use exception; consult your compliance requirements.
No. CapyToolkit's Hash Generator computes MD5 locally in your browser, so the text or file you enter is not uploaded to produce the 32-character digest. Use the result for compatibility checks, not for security-sensitive trust decisions.
What Is HMAC?
Because a plain hash proves nothing about who produced it, systems that need to authenticate a message's origin use HMAC1. Anyone with the input can reproduce a SHA-256 hash - but only someone with the secret key can reproduce an HMAC1. This single property makes HMAC the foundation of API authentication, webhook verification, and session integrity checking.
What is HMAC?
HMAC(K, M) = H(K' XOR opad || H(K' XOR ipad || M)), where H is a hash function such as SHA-256, K' is the key padded to the block size, and ipad/opad are fixed constants2. The result is an authentication tag that proves both the integrity of the message and that the sender knew the key. RFC 2104 recommends a key at least as long as the hash output3.How HMAC differs from a plain hash
A plain hash depends only on the input. HMAC depends on both the input and a secret key. Consequently, two parties who share the key can both compute the HMAC for a given message and verify it matches - but a third party who sees the message and its HMAC cannot produce the same HMAC for a modified message without knowing the key. This property is called message authentication, distinct from integrity checking (which only detects changes) because it also proves the identity of the sender.
When a plain hash is not enough
Use HMAC when the verifier must know that the sender possessed a shared secret. A plain SHA-256 digest is useful for detecting accidental changes, but anyone who sees the message can compute the same digest. HMAC adds the missing authentication property without turning the message into ciphertext. The key insight is that authentication and integrity are separate concerns: a hash gives you integrity, but only HMAC or a digital signature can give you authentication, which is why protocols like webhook verification and API request signing always use HMAC rather than bare hashes.
You reach for HMAC whenever the verifier must confirm that the sender held a shared secret, not merely that the message is unchanged. A plain SHA-256 digest proves integrity, but anyone who sees the message can compute the same value without the key. CapyToolkit computes HMAC locally so you can inspect the tag format before wiring the verification step into an API or webhook handler.
Security properties and algorithm independence
HMAC's security is proven to hold as long as the underlying hash function is collision-resistant and has certain pseudo-random properties that prevent an attacker from predicting the output without knowing the key. Building on this theoretical foundation: HMAC-SHA256 inherits SHA-256's security and currently has no known practical attacks that would allow forgery or key recovery4. HMAC-MD5 is still considered secure for message authentication because collision resistance in the hash is not directly exploited in the HMAC construction, despite MD5's collision vulnerabilities in other contexts5. Yet modern designs use HMAC-SHA256 or HMAC-SHA512 exclusively, since MD5 carries reputational risk even when technically adequate for a specific use.
Common applications of HMAC
HMAC-SHA256 is the basis for most API request authentication because it provides a way to prove that a message came from a holder of the shared secret without ever transmitting the secret itself. GitHub uses it for webhook signature headers (X-Hub-Signature-256). Stripe includes it in payment event verification (Stripe-Signature). JWT HS256 tokens use HMAC-SHA256 with a server-side secret. AWS Signature Version 4 applies HMAC-SHA256 four times to derive a scoped signing key6. Furthermore, HMAC-SHA1 remains in legacy systems: Google OAuth 1.0, older TOTP seeds (RFC 6238 uses HMAC-SHA1 by default for time-based OTPs), and legacy HMAC-based KDF schemes.
Choosing the HMAC hash algorithm
For new systems, prefer HMAC-SHA256 unless the protocol specifies HMAC-SHA512. SHA-256 gives enough security margin for almost every application and keeps signatures shorter. SHA-512 is appropriate when a standard explicitly requires it or when long-lived keys justify the larger tag. The 64-character hex output of HMAC-SHA256 fits comfortably in most HTTP headers and log formats, while HMAC-SHA512's 128-character output can exceed header size limits in some web servers and proxies, which is a practical reason to default to SHA-256 unless you have a specific requirement for the longer digest.
HMAC key storage, minimum length, and rotation practices
Store HMAC keys in environment variables or a dedicated secrets manager rather than in source code. Embedding a key in code exposes it in version control history and to anyone with repository read access. Generate keys with a cryptographically secure random generator: os.urandom(32) in Python, crypto.randomBytes(32) in Node.js. RFC 2104 recommends a key at least as long as the hash output; use 32 bytes for HMAC-SHA256.
Rotate keys by deploying the new key alongside the old one, accepting signatures from both during a transition window, then decommissioning the old key once all tokens or messages signed with it have expired. Most JWT libraries support multiple active signing keys for exactly this rotation. Log key version identifiers in signed tokens so rotation events are auditable without exposing the secret material itself.
Because HMAC requires a shared key, it suits closed-system authentication
Because HMAC requires both parties to share the same secret, it fits closed systems where you control both the signer and the verifier. When a third party must verify your signature without a prior key exchange, use an asymmetric scheme: RSA-SHA256, ECDSA-P256, or Ed25519. JWT RS256 and ES256 tokens, TLS certificates, and software package signing all use asymmetric signatures for this reason.
HMAC is faster than asymmetric signing and requires no public key infrastructure. For internal API authentication, webhook verification, and session integrity where key distribution is fully under your control, HMAC-SHA256 is simpler and adequate. Use asymmetric signatures when you need public verifiability, certificate-based identity, or the ability to revoke trust without rotating a shared secret across all parties.
Avoiding client-side service secrets
Do not place a service HMAC key in public browser code. HMAC is appropriate in browsers only when the browser is the trusted key holder, such as a local developer tool or extension owned by the user. For public web apps, keep the secret on the server and verify signatures before processing application state. Any secret embedded in JavaScript that ships to the browser is readable by anyone who opens the developer tools, which means an attacker can extract the key and forge valid HMAC signatures for arbitrary messages, completely bypassing your authentication layer.
Try in the tool
What to look for
- Recommended HMAC-SHA256 key length 32 bytes (256 bits), per RFC 2104
- HMAC-SHA256 forgery security 256-bit
- HMAC-MD5 forgery security about 128-bit
Open the Hash Generator: MD5, SHA-1, SHA-256 & SHA-512 tool to try this yourself.
Open the tool →- 1.
H. Krawczyk, M. Bellare, R. Canetti, "HMAC: Keyed-Hashing for Message Authentication," RFC 2104, rfc-editor.org, February 1997. https://www.rfc-editor.org/rfc/rfc2104
- 2.
NIST, "The Keyed-Hash Message Authentication Code (HMAC)," FIPS 198-1, nist.gov, July 2008. https://csrc.nist.gov/pubs/fips/198-1/final
- 3.
S. Turner, L. Chen, "Updated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 Algorithms," RFC 6151, rfc-editor.org, March 2011. https://www.rfc-editor.org/rfc/rfc6151
- 4.
"HMAC," Wikipedia, accessed June 2026. https://en.wikipedia.org/wiki/HMAC
- 5.
GitHub, "Validating webhook deliveries," docs.github.com, accessed June 2026. https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries
- 6.
AWS, "Create a signed AWS API request," docs.aws.amazon.com, accessed June 2026. https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html
SHA-256 hashes a message with no key. Anyone can reproduce a SHA-256 hash from the message alone. HMAC-SHA256 mixes a secret key into the computation. Without the key, an observer cannot reproduce the HMAC, so it authenticates both the message content and the sender's possession of the key.
No. HMAC produces an authentication tag, not ciphertext. It does not hide the message content. A transmitted HMAC proves the message was sent by a key holder and was not modified, but the message itself is still readable. For confidentiality, combine HMAC with encryption (authenticated encryption modes like AES-GCM combine both in one operation).
Yes. HMAC is algorithm-agnostic by design: HMAC-SHA256, HMAC-SHA512, HMAC-SHA1, and HMAC-MD5 all exist. The security strength of the resulting HMAC is bounded by the security of the underlying hash. HMAC-SHA256 provides 256-bit security against forgery; HMAC-MD5 provides roughly 128-bit security for forgery (though MD5 collision vulnerabilities do not directly apply to HMAC).
RFC 2104 recommends a key at least as long as the hash output: 32 bytes (256 bits) for HMAC-SHA256. Shorter keys reduce the effective security. Longer keys are acceptable but do not increase security beyond the hash output length. Keys should be random - derived from a CSPRNG like os.urandom(32) in Python.
Yes. TLS protects data in transit, but HMAC protects application-level message integrity independently of the transport layer. If a webhook is delivered over HTTPS but your server does not verify the HMAC, a compromised intermediary with a valid TLS certificate could forge the payload. Defense in depth recommends verifying HMAC even over TLS.
No. CapyToolkit's Hash Generator computes HMAC values locally in your browser, so the secret and message are not uploaded to produce the tag. Treat real service secrets as sensitive and avoid entering shared production keys into public machines.
Hash vs Encryption
Confusing hashing with encryption is one of the most common security mistakes in application development. Because both operations transform input data into an unrecognizable output, they look similar from the outside.1 Yet the two serve fundamentally different purposes - and using one where the other is required causes serious security vulnerabilities.
What is hash vs encryption?
Reversibility: the fundamental difference
Encryption is designed to be reversible. AES-256 encryption with the right key always recovers the original plaintext. Hashing is designed to be irreversible - given a SHA-256 digest, there is no mathematical operation that recovers the original input.2 This is not a limitation; it is the feature. Systems that store password hashes rely on irreversibility: even if an attacker steals the hash database, they cannot recover passwords. Conversely, using hashing instead of encryption for data that must be recovered later - user addresses, medical records, API keys that need to be displayed - results in permanent data loss.
Matching the operation to the recovery requirement
Ask whether you need the original value later. If yes, encrypt it. If you only need to compare it or prove it has not changed, hash it. That question prevents the most common design mistake before you choose algorithms, key storage, or database columns. A practical test: if a user calls support and asks you to look up their original data, you need encryption, because a hash gives you no way to reconstruct the original value regardless of how much computing power you throw at it.
You avoid permanent data loss by asking whether the original value must surface later, because that single question settles the hashing versus encryption choice. Encrypt the data when a support request might need to read it back, and hash it only when comparison or integrity is the goal. CapyToolkit computes hashes locally so you can compare digest formats without uploading the value you intend to store or transmit.
Fixed vs variable output and key requirements
Hash functions always produce the same-length output regardless of input size: SHA-256 always produces 64 hex characters, whether the input is one byte or one gigabyte. Encryption output is typically proportional to input size - encrypting a 1 MB file produces approximately 1 MB of ciphertext. Furthermore, encryption requires a key - without the decryption key, the ciphertext is unusable. Hashing requires no key (though HMAC adds a key to a hash for authentication purposes). This distinction drives the choice: hash for fingerprinting, comparison, and integrity; encrypt for storage and transmission of data that must later be recovered.
Remembering that HMAC is different again
HMAC is not plain hashing and not encryption. It adds a secret key to a hash so two trusted parties can authenticate a message. Use HMAC when you need to prove who produced the value, but do not expect HMAC to hide the message content. Think of it as a sealed envelope versus a locked box: a plain hash is like a wax seal that anyone can verify but anyone can also produce, encryption is a locked box that hides the contents, and HMAC is a seal that only someone with the right signet ring can produce, proving authenticity without hiding the message.
Common security mistakes from confusion
The most damaging confusion is storing passwords as plain SHA-256 hashes. This is not encryption - it provides no confidentiality for the password and the hash is trivially reversible using precomputed lookup tables. Building on this problem: SHA-256 is also fast (billions of hashes per second on a GPU), making brute force trivial for common passwords.1 The correct approach for password storage is a slow, salted hash function: bcrypt, scrypt, or Argon2. A second common mistake is encrypting data and assuming the ciphertext provides integrity - AES-CBC, for example, can be modified in predictable ways without the key (padding oracle attacks).3 Authenticated encryption modes like AES-GCM provide both confidentiality and integrity.
Avoiding one-way storage for recoverable data
Do not hash values you still need to display, export, or search in plaintext form. Hashing an email address for lookup may help with indexing, but it cannot replace encryption when a support team must recover the original address for a legitimate user request. Once a value is hashed, the original is gone forever unless you stored it separately, which means any business process that requires reading the original back, such as sending a confirmation email or generating a customer report, will fail unless you planned for encryption instead of hashing from the start.
Authenticated encryption combines confidentiality and integrity correctly
AES-256-GCM and ChaCha20-Poly1305 are authenticated encryption modes that provide confidentiality and integrity in a single operation. AES-GCM computes a GHASH authentication tag over the ciphertext4; ChaCha20-Poly1305 uses Poly1305 as the MAC.5 Both modes reject modified ciphertext before decryption proceeds, preventing the padding oracle attacks that affect unauthenticated modes such as AES-CBC, where an attacker can alter ciphertext in predictable ways.
For new systems that need both encryption and integrity, choose AES-256-GCM or ChaCha20-Poly1305 as a single primitive rather than combining AES-CBC with a separate HMAC. The combined mode eliminates the ordering question (encrypt-then-MAC vs MAC-then-encrypt) that makes manual composition error-prone, and both algorithms have well-supported implementations in every major cryptographic library.
When your design needs both hashing and encryption for the same value
Some systems need to search for a specific value without decrypting every stored record. A practical pattern: hash the plaintext with HMAC-SHA256 using a server-side secret and store the result as a searchable index, then encrypt the plaintext with AES-256-GCM for storage.6 Equality queries compare against the HMAC index without touching the encrypted column. The encrypted column protects the original value from unauthorized access.
Using HMAC rather than plain SHA-256 for the index prevents a rainbow table attack against the indexed column, because the HMAC key adds entropy the attacker does not possess. This pattern appears in privacy-preserving databases that need to check whether a phone number or email address is registered without exposing the plaintext values to direct queries.7
Try in the tool
What to look for
- SHA-256 output length always 64 hex characters, regardless of input size
- Encryption output size roughly proportional to input size (a 1 MB file yields ~1 MB of ciphertext)
- Password storage use a slow, salted function (bcrypt, scrypt, or Argon2), never plain SHA-256
- Authenticated encryption AES-256-GCM or ChaCha20-Poly1305 for confidentiality plus integrity in one primitive
Hashing has no key and is one-way; encryption requires a key and is reversible; HMAC adds a key to a hash for authentication without hiding the message.
Open the Hash Generator: MD5, SHA-1, SHA-256 & SHA-512 tool to try this yourself.
Open the tool →- 1.
OWASP, "Password Storage Cheat Sheet," cheatsheetseries.owasp.org, 2024. https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
- 2.
NIST, "Secure Hash Standard (SHS)," FIPS 180-4, nist.gov, March 2012. https://csrc.nist.gov/pubs/fips/180-4/final
- 3.
"Padding oracle attack," Wikipedia, accessed June 2026. https://en.wikipedia.org/wiki/Padding_oracle_attack
- 4.
NIST, "Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC," SP 800-38D, nist.gov, November 2007. https://csrc.nist.gov/pubs/sp/800-38/d/final
- 5.
Y. Nir, A. Langley, "ChaCha20 and Poly1305 for IETF Protocols," RFC 8439, IETF, June 2018. https://www.rfc-editor.org/rfc/rfc8439
- 6.
"HMAC," Wikipedia, accessed June 2026. https://en.wikipedia.org/wiki/HMAC
- 7.
AWS, "What is the AWS Database Encryption SDK?," docs.aws.amazon.com, accessed June 2026. https://docs.aws.amazon.com/database-encryption-sdk/latest/devguide/what-is-database-encryption-sdk.html
No. SHA-256 is not encryption and has no decryption operation. The only way to find an input for a given SHA-256 hash is brute force. For short or common inputs (dictionary words, phone numbers), precomputed lookup tables (rainbow tables) can reverse the hash. For long, complex, or random inputs, brute force is computationally infeasible.
Neither hashing nor encryption - Base64 is plain encoding. Anyone can decode Base64 without any key: it simply converts binary data to a text-safe format. Base64 provides no security. Data encoded as Base64 is just as readable as the original once decoded.
Hash when you need to compare data without storing it (passwords, sensitive query parameters), verify data integrity (file checksums, message authenticity with HMAC), or create a fixed-size identifier from variable-length input. Encrypt when you need to store or transmit data and recover the original value later.
Authenticated encryption (AE) combines encryption for confidentiality with a MAC for integrity in a single operation. AES-GCM and ChaCha20-Poly1305 are common AE modes. Without the authentication component, ciphertext can be modified in ways that produce different plaintext without the attacker knowing the key. AE prevents this. Use AES-GCM or ChaCha20-Poly1305 for new systems rather than AES-CBC.
HMAC is neither encryption nor a plain hash - it is a message authentication code. HMAC produces an unforgeable tag that proves message integrity and sender identity (because the tag requires knowledge of the key). It does not hide the message content (no confidentiality). Use HMAC for authentication; use encryption for confidentiality; use both (AE) when you need both properties.
Yes. CapyToolkit's Hash Generator computes hashes and HMAC values in your browser, so you can compare digest lengths and output formats without uploading input or secrets.