Short answer
Hashing maps data of any length to a short, fixed-size digest. You cannot treat that digest as a file you can decrypt back into the original input. FIPS 180-4 calls SHA-256 and its relatives one-way hash functions, and it says finding a message for a given digest is computationally infeasible. MDN lists SHA-256's output at 256 bits.
Last verified against the sources listed below.
Key takeaways
- A hash function turns an input into a fixed-size digest.
- FIPS 180-4 calls these algorithms one-way. The digest is not the original file.
- SHA-256's message digest size in that standard is 256 bits.
- Encryption uses a key and has a decrypt operation. Hashing does not.
- Base64 changes representation. It is not a hash, and it can be decoded.
What is hashing, in the Secure Hash Standard, is a one-way function that turns a message into a fixed-size digest. The digest is a fingerprint. It is not a locked box you open with a password, and it is not a different spelling of the same bytes.
Website security uses hashes for checks such as whether a file changed. This page stays on the definition: what a digest is, why it is not reversible, and how that differs from encryption and from Base64.
What does a hash function produce?
It produces a fixed-size digest from an input of any practical length. MDN calls a digest a short fixed-length value derived from variable-length input. Cryptographic digests should be collision-resistant: it should be hard to find two different inputs with the same digest value.
FIPS 180-4 specifies SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256. It says each one is an iterative, one-way hash function. The output is a message digest, a condensed representation of the data. The point it states is integrity: a change in the message should, with very high probability, change the digest.
That property is why digests show up with digital signatures, message authentication codes, and random-bit generation.
The standard describes two stages. Preprocessing pads the message, splits it into blocks, and sets initial values. Hash computation then walks those blocks and produces the digest. You do not need the inner rounds to use the result.
You need to know the digest is a fixed length and that a matching digest is evidence the inputs matched, not a copy of the input.
Can you reverse a digest?
No. The standard’s own security claim is that it is computationally infeasible to find a message that corresponds to a given digest, and infeasible to find two messages with the same digest. “Infeasible” is the word in FIPS 180-4. It is not a claim that every historical hash still meets that bar.
MDN warns that SHA-1 should not be used for cryptographic applications. Python’s hashlib documentation says MD5 and SHA-1 have known collision weaknesses, and it still documents them because old systems call them. The constructors that the Python page says are always present include sha256(), sha384(), and sha512(), along with the weaker names. For a new fingerprint, the pages point you at the SHA-2 family, not at MD5.
A digest also does not shrink and expand like a zip file. Compression is built to restore the bytes. A hash throws away the path back. Two different files can, in theory, share a digest.
The design goal is to make that collision impractical for the algorithms the standard still recommends.
How is hashing different from encryption?
Encryption is reversible with a key. Hashing is not. MDN’s encrypt method takes an algorithm, a key, and the plaintext, and it returns ciphertext. The page says decrypt is the matching operation, and it lists AES modes and RSA-OAEP as algorithms that support both.
You keep the key, or the private key, if you need the original data back.
The digest method does not take a key. MDN says you pass an algorithm name, such as SHA-256, and the data, and you receive an ArrayBuffer of the digest. The whole input has to be in memory. The API does not stream.
The W3C Web Cryptography API specifies that digest operation as its own method, separate from encrypt and decrypt in the algorithm tables.
| Operation | What you put in | What you get back | Can you recover the input? |
|---|---|---|---|
| SHA-256 digest | The message and the algorithm name | A 256-bit digest | Not by design. FIPS 180-4 calls the function one-way. |
| Encrypt | Plaintext plus a key | Ciphertext | Yes, with the matching decrypt and key, per MDN. |
| Base64 | Bytes | ASCII text that represents those bytes | Yes. MDN documents decoding back to the bytes. |
How the internet works moves those bytes in requests. A hash of a file and an encrypted file can both appear in that traffic. They answer different questions. The hash answers “did this change?” The ciphertext answers “can the key holder read this?”
What size is a SHA-256 digest?
256 bits. FIPS 180-4 Figure 1 lists the message digest size for SHA-256 as 256 bits. The same row lists a 512-bit block and a 32-bit word. MDN’s digest table agrees: output length 256 bits, block size 512 bits, and it cites FIPS 180-4 section 6.2.
Neighboring rows in that MDN table are easy to mix up. SHA-1 is 160 bits. SHA-384 is 384 bits. SHA-512 is 512 bits.
FIPS 180-4 also lists SHA-224 at 224 bits and the truncated SHA-512 variants at 224 and 256 bits. The name SHA-256 means the 256-bit digest, not “256 rounds you can ignore.”
Python’s hashlib page shows the call shape. sha256() returns a hash object. You pass bytes to update(), and you read digest() or hexdigest(). The documentation page opened in December 2026 is the Python 3 hashlib page.
It says the SHA-224, SHA-256, SHA-384, and SHA-512 algorithms there are the ones defined in FIPS 180-4. It does not print a sample digest you should memorize. Compare hex strings only when you computed both from the same bytes.
Where do encoding and hashing diverge?
Encoding changes the alphabet. Hashing changes the data into a fingerprint. MDN says Base64 represents binary data as ASCII text, using a 64-character alphabet, so the bytes survive a channel that wants text. Four Base64 characters stand for three bytes.
The string is larger than the input, and it can be decoded.
btoa and atob are the browser pair MDN names for that encode and decode step. They are not digest functions. If you Base64-encode an SVG, you can Base64-decode it and get the SVG back. If you hash the SVG, you get a digest, and FIPS 180-4 says you should not be able to rebuild the file from that digest.
The SVG to Base64 tool only does the encoding. Use it when a text field has to hold an SVG. Use SubtleCrypto.digest, or hashlib.sha256, when you need the fingerprint. Mixing the two up is how a “hash” ends up reversible, which means it was never a hash.
Frequently asked questions
What is hashing in one sentence?
Hashing runs data through a function that produces a fixed-size digest. MDN describes a digest as a short fixed-length value derived from a variable-length input. FIPS 180-4, the Secure Hash Standard, says its algorithms are iterative one-way hash functions that produce a condensed representation called a message digest. The digest is useful for checking whether a message changed.
Can you reverse a hash to get the input back?
Not in the sense these standards describe. FIPS 180-4 says the algorithms are called secure because, for a given algorithm, it is computationally infeasible to find a message that corresponds to a given digest, or to find two different messages that produce the same digest. Any change to the message should, with very high probability, produce a different digest.
How is hashing different from encryption?
Encryption is built to be reversed with a key. MDN's encrypt method takes a key and plaintext and returns ciphertext. The same page says the Web Crypto API provides encrypt and decrypt operations. Hashing, on the digest method, takes an algorithm name and the data, and returns a fixed-length digest. It does not take a key, and FIPS 180-4 describes the result as one-way.
How long is a SHA-256 digest?
256 bits. FIPS 180-4 Figure 1 lists SHA-256 with a message digest size of 256 bits, a block size of 512 bits, and a word size of 32 bits. MDN's table for SubtleCrypto.digest lists SHA-256 with an output length of 256 bits and a block size of 512 bits, and it points at FIPS 180-4.
Is Base64 a kind of hashing?
No. MDN defines Base64 as a binary-to-text encoding that represents bytes as an ASCII string so the data can travel through systems that want text. Encoding is reversible. The browser provides atob to decode what btoa encoded. A hash does not offer that return path. The SVG to Base64 tool only changes representation of an SVG.
Sources
- FIPS 180-4 Secure Hash Standard · NIST, 2026
- SubtleCrypto.digest() · MDN, 2026
- SubtleCrypto.encrypt() · MDN, 2026
- Base64 · MDN, 2026
- hashlib · Python, 2026
- Web Cryptography API · W3C, 2026