---
slug: hash-length-calculator
title: "Hash Length Calculator"
category: developer
updated: 2026-11-17
canonical: https://calcseed.com/c/developer/hash-length-calculator/
html: /c/developer/hash-length-calculator/
---

# Hash Length Calculator

See the output length of common hash algorithms in bits, bytes and hex characters. Free and instant.

## Quick answer

**Quick answer:** with the default inputs (md5, 100 chars), the digest length is **128**. At these inputs: bytes = **16**, hex characters = **32**. Change any input to update the result.

## Default calculation

Values computed by this calculator at exactly the default inputs listed below.

### Inputs (defaults)

| Input | Value | Unit |
| --- | --- | --- |
| Algorithm | md5 |  |
| Input length | 100 | chars |

### Outputs at these defaults

| Output | Value | Unit |
| --- | --- | --- |
| Digest length | 128 |  |
| Bytes | 16 |  |
| Hex characters | 32 |  |

## Formula

```text
bytes = bits ÷ 8    hex chars = bytes × 2
```

## Inputs

| Variable | Type | Unit | Default |
| --- | --- | --- | --- |
| Algorithm | select |  | md5 |
| Input length | number | chars | 100 |

## Outputs

| Result | Format |
| --- | --- |
| Digest length | primary |
| Digest length | number |
| Bytes | number |
| Hex characters | number |

## How it works

### What this calculator returns

Choose MD5, SHA-1, SHA-256 or SHA-512 and the tool prints the digest length in three units at once: bits, bytes and hex characters. At the default selection of MD5 with a 100-character input the answer is **128 bits**, which is **16 bytes** or **32 hex characters**. The input length is carried through for reference but never changes the digest size.

### How bits, bytes and hex characters relate

A digest is a binary string. The algorithm defines its length in bits, and every other figure on the page is derived from that single number. One byte holds 8 bits, so you divide the bit count by 8 to get bytes. Hexadecimal writes each byte as two characters drawn from 0–9 and a–f, so the hex string is exactly twice the byte count.

That is the whole arithmetic. 128 ÷ 8 = 16 bytes, and 16 × 2 = 32 hex characters for MD5. SHA-256 gives 256 ÷ 8 = 32 bytes and 32 × 2 = 64 hex characters. SHA-512 gives 64 bytes and 128 hex characters. No other factor enters, which is why the three numbers always move together when you switch the dropdown.

#### Why the hex form is the one you usually see

Command-line tools such as md5sum, shasum and certutil print hex because it is compact, case-insensitive to compare and safe to paste into a bug ticket. The raw 16-byte binary digest is unreadable and easy to corrupt in transit, so hex became the default exchange format. Some systems use Base64 instead, which encodes those same 16 bytes as 24 characters including padding — shorter than 32 hex characters, but not interchangeable with it.

### Worked example at the defaults

The defaults are MD5 with a 100-character input. MD5 always emits 128 bits regardless of what you feed it, so the 100 characters affect nothing but the reference label in the output.

Step one: the algorithm map resolves md5 to 128 bits. Step two: 128 ÷ 8 = 16 bytes. Step three: 16 × 2 = 32 hex characters. The calculator returns outputBits = 128, outputBytes = 16 and hexChars = 32.

Switch to SHA-256 with the same 100-character input and the three figures become 256, 32 and 64. The input did not grow; only the algorithm changed. A SHA-512 digest of that same string is 64 bytes and 128 hex characters, four times the MD5 output for identical input.

| Algorithm | Digest bits | Bytes | Hex chars | Base64 chars | Status |
| --- | --- | --- | --- | --- | --- |
| MD5 | 128 | 16 | 32 | 24 | Broken for collisions |
| SHA-1 | 160 | 20 | 40 | 28 | Deprecated |
| SHA-256 | 256 | 32 | 64 | 44 | Recommended |
| SHA-512 | 512 | 64 | 128 | 88 | Recommended |

The Base64 column follows the 3-bytes-to-4-characters rule: a 16-byte MD5 digest pads to 18 bytes across six 3-byte groups and yields 24 characters. That matters when a digest is stored in a JSON field or a URL segment where the 32-character hex form is too wide.

### Why input length never changes the digest

Hash functions are built to consume any amount of data and emit a fixed-size result. MD5, SHA-1 and the SHA-2 family use Merkle–Damg&aring;rd construction: the message is split into fixed blocks, padded, and folded through a compression function one block at a time. The final internal state is the digest, and its width is set by the algorithm, not by the message.

Padding is why a zero-length input still produces a full digest: MD5 of an empty string is still 32 hex characters. The rule appends at least one byte and enough zeros to reach a block boundary, plus a length field. This is also why hashing a 100-character string and a 4 GB ISO image with the same algorithm hands you back the same 32 or 64 characters.

### Where digest length changes an engineering decision

- Storage: one million SHA-256 digests in hex text need 64 MB, against 32 MB if you store the raw 32-byte value
- Index width: a char(64) key doubles index size and page splits compared with char(32) at the same row count
- Payload size: a hex SHA-256 digest is 64 characters, its Base64 form is 44, roughly a third smaller on the wire
- Security margin: a 128-bit hash has a 2^64 birthday bound, too small for collision resistance today
- Truncation: cutting a SHA-256 hex string to 16 characters keeps 64 bits, fine for a checksum but not for a signature

The storage math is worth doing before you pick a column type. A 10-million-row table keyed by a 64-character hex SHA-256 holds 640 MB of key text alone; storing the 32-byte binary value instead halves that and keeps comparisons exact.

### Common mistakes

- Confusing bits with bytes: a 128-bit MD5 digest is 16 bytes, not 128 bytes
- Counting hex characters as bytes: 32 hex characters represent 16 bytes
- Assuming a longer digest is automatically safer: 512 bits do not fix a leaked key or an unsalted password table
- Truncating a hex string mid-pair: cutting to 31 characters drops half a byte and breaks decoding
- Reading the 100-character input as the output size: the input field never sets the digest length
- Expecting md5sum output to grow with the file: it is always 32 characters for any file size

#### Hex case and separators

Upper and lower case hex encode the same bytes and both run 32 or 64 characters. Some tools insert spaces or colons between byte pairs for readability, and certutil prints digests in this spaced form, which inflates the visible character count without changing the digest. Strip separators before comparing two hashes, and compare case-insensitively unless the specification says otherwise.

### Choosing an algorithm by digest length

If you need collision resistance for certificates or signatures, 256 bits is the practical floor and SHA-256 is the default choice. If you only need to detect accidental corruption in a download, 128-bit MD5 or 160-bit SHA-1 still flags a bad transfer, but both are broken for adversarial use and should not guard anything an attacker wants to forge. SHA-512 costs more CPU per byte on 32-bit hardware yet is often faster on 64-bit CPUs, so its 64-byte output rarely slows a modern server.

## FAQ

### How long is an MD5 hash?

An MD5 digest is 128 bits, which is 16 bytes and 32 hex characters. Encoded as Base64 the same digest is 24 characters including padding.

### How many hex characters is a SHA-256 hash?

SHA-256 produces 256 bits, equal to 32 bytes and 64 hex characters. The Base64 form of the same digest is 44 characters.

### Does input length change the hash length?

No. MD5 returns 32 hex characters whether the input is 1 character or 10 GB. The algorithm pads the message to block boundaries but the digest width stays fixed at 128 bits.

### How long is a SHA-512 hash?

SHA-512 emits 512 bits, which is 64 bytes, 128 hex characters or 88 Base64 characters.

### Why is my SHA-1 hash 40 characters?

SHA-1 is 160 bits. Divide by 8 to get 20 bytes, then multiply by 2 for 40 hex characters.

### Is a 32-character hash always MD5?

Not necessarily. 32 hex characters mean 128 bits, which fits MD5 but also a truncated SHA-256 or another 128-bit function. Check which tool produced it rather than guessing from length.

### What is the shortest hash considered secure today?

256 bits for collision resistance. A 128-bit digest caps the birthday attack at about 2^64 operations, which is within reach of well-funded attackers; SHA-256 raises that to 2^128.

### How many bytes is a SHA-256 digest in binary form?

32 bytes. Storing it as hex doubles the footprint to 64 bytes per digest, which is why binary columns are half the size of text columns at scale.

### Can two different inputs produce the same hash?

Yes, collisions exist by definition because the digest is shorter than the input space. Practical MD5 collisions were demonstrated in seconds; no practical SHA-256 collision is known.

### Does hashing a password produce a fixed 64-character string?

Only if you use plain SHA-256 without a salt. Password storage should use bcrypt, scrypt or Argon2, whose outputs are longer and deliberately slow, not a fast 64-character hex digest.

## Method and sources

Methodology: Conversions and formats follow the relevant IETF RFCs and IEEE standards, including RFC 4648 for Base64 and RFC 791 for IPv4 addressing.

Last updated: 2026-11-17.
- Digest lengths: MD5 = 128 bit, SHA-1 = 160 bit, SHA-256 = 256 bit, SHA-512 = 512 bit.
