SHA-224 Hash Length Overview
The SHA-224 hash function produces a fixed-size output of exactly 224 bits (28 bytes), regardless of the input size. This 224-bit length is a defining characteristic of the algorithm and is reflected in its name. The hash value is typically represented as a 56-character hexadecimal string in most applications.
SHA-224 Output at a Glance
- Bit Length: 224 bits
- Byte Length: 28 bytes
- Hexadecimal Representation: 56 characters
- Base64 Representation: 38 characters (with padding)
- Binary Representation: 224 characters (0s and 1s)
Example SHA-224 hash of the text "Hello, world!":
4575bb4ec129df6380cedde6d71217fe0536f8ffc4e18bca530a7a1b
This 56-character string is the hexadecimal representation of the 224-bit hash value. Each hexadecimal character represents 4 bits, so 56 characters × 4 bits = 224 bits.
Why 224 Bits?
The 224-bit length of SHA-224 was carefully chosen for specific reasons:
Security Level
SHA-224 provides 112 bits of security against collision attacks, which is the security level required for many applications using 112-bit symmetric encryption schemes. This is because, due to the birthday paradox, a hash function with n bits of output generally provides n/2 bits of collision resistance.
Relation to SHA-256
SHA-224 is essentially SHA-256 with different initialization values and truncated output. The 224-bit length makes it exactly 32 bits (4 bytes) shorter than SHA-256, which produces a 256-bit output.
Efficiency Trade-off
The 224-bit length offers a balance between security and efficiency, with a 12.5% reduction in hash size compared to SHA-256, which can be significant in bandwidth-constrained environments.
Compatibility
The 224-bit (28-byte) length is evenly divisible by 8, making it byte-aligned and easy to work with in most computing environments and programming languages.
NIST created SHA-224 specifically for applications that needed an intermediate security level between SHA-1 (160 bits) and SHA-256 (256 bits), while maximizing compatibility with SHA-256 implementations.
SHA-224 Length Comparison
How does the 224-bit length of SHA-224 compare to other hash functions?
Hash Algorithm | Output Size (bits) | Output Size (bytes) | Hex String Length | Security Level (bits) |
---|---|---|---|---|
MD5 | 128 | 16 | 32 | ~18 (broken) |
SHA-1 | 160 | 20 | 40 | ~63 (compromised) |
SHA-224 | 224 | 28 | 56 | 112 |
SHA-256 | 256 | 32 | 64 | 128 |
SHA-384 | 384 | 48 | 96 | 192 |
SHA-512 | 512 | 64 | 128 | 256 |
SHA3-224 | 224 | 28 | 56 | 112 |
SHA3-256 | 256 | 32 | 64 | 128 |
As shown in the table, SHA-224 sits between SHA-1 and SHA-256 in terms of output length. It offers significant security improvements over SHA-1 while being slightly more compact than SHA-256.

Figure 1: Comparison of output lengths (in bits) across common hash algorithms
Hash Length Representations
The 224-bit (28-byte) output of SHA-224 can be represented in several different formats:
1. Hexadecimal Representation (Most Common)
A 56-character string of hexadecimal digits (0-9, a-f):
4575bb4ec129df6380cedde6d71217fe0536f8ffc4e18bca530a7a1b
2. Base64 Representation
A 38-character string (including padding) using Base64 encoding (A-Z, a-z, 0-9, +, /):
RXW7TsEp32OAzt3m1xIX/gU2+P/E4YvKUwp6Gw==
3. Binary Representation
A 224-character string of 0s and 1s:
01000101011101011011101101001110110000010010100111011111011000111000000011001110110111011110011011010001001000010111111111100000010100110110111110001111111111000100111000011011110010100101000111010100001011
4. Raw Bytes
28 bytes of binary data, often stored in data structures or transmitted in binary protocols.
5. URL-Safe Encoding
A URL-safe version of Base64 that replaces + with - and / with _:
RXW7TsEp32OAzt3m1xIX_gU2-P_E4YvKUwp6Gw==
Representation Efficiency
When choosing a representation format, consider these efficiency factors:
- Hexadecimal: Simple, human-readable, but 2x the size of raw bytes
- Base64: ~33% larger than raw bytes, but more compact than hex
- Raw Bytes: Most efficient for storage and transmission
- Binary: Least efficient (8x raw bytes), rarely used except for teaching
Working with SHA-224 Length in Programming
When implementing SHA-224 in various programming languages, you'll need to handle the 224-bit (28-byte) output appropriately:
JavaScript Example
// Using the Web Crypto API
async function sha224Hash(message) {
// Convert message string to bytes
const msgBuffer = new TextEncoder().encode(message);
// Note: Web Crypto doesn't directly support SHA-224, so use SHA-256 and truncate
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
// Convert to byte array
const hashArray = Array.from(new Uint8Array(hashBuffer));
// Take only first 28 bytes (224 bits)
const sha224Array = hashArray.slice(0, 28);
// Convert to hex string
const hashHex = sha224Array.map(b => b.toString(16).padStart(2, '0')).join('');
console.log(`SHA-224 hash: ${hashHex}`);
console.log(`Hash length in bits: ${sha224Array.length * 8}`);
console.log(`Hash length in bytes: ${sha224Array.length}`);
console.log(`Hex string length: ${hashHex.length}`);
return hashHex;
}
Python Example
import hashlib
import base64
def sha224_demo(message):
# Create a SHA-224 hash object
sha224 = hashlib.sha224()
# Update with message bytes
sha224.update(message.encode('utf-8'))
# Get the hash digest as bytes (28 bytes / 224 bits)
digest_bytes = sha224.digest()
# Get the hexadecimal representation (56 characters)
hex_digest = sha224.hexdigest()
# Get the Base64 representation
base64_digest = base64.b64encode(digest_bytes).decode('utf-8')
# Create binary representation
binary_digest = ''.join(format(byte, '08b') for byte in digest_bytes)
print(f"Message: {message}")
print(f"SHA-224 hash (hex): {hex_digest}")
print(f"SHA-224 hash (Base64): {base64_digest}")
print(f"Hash length in bits: {len(digest_bytes) * 8}")
print(f"Hash length in bytes: {len(digest_bytes)}")
print(f"Hex string length: {len(hex_digest)}")
print(f"Base64 string length: {len(base64_digest)}")
return hex_digest
# Example usage
sha224_demo("Hello, world!")
Java Example
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
public class SHA224Demo {
public static void main(String[] args) throws NoSuchAlgorithmException {
String message = "Hello, world!";
// Create SHA-224 MessageDigest instance
MessageDigest digest = MessageDigest.getInstance("SHA-224");
// Update with message bytes
byte[] hashBytes = digest.digest(message.getBytes(StandardCharsets.UTF_8));
// Convert to hexadecimal representation
StringBuilder hexString = new StringBuilder();
for (byte b : hashBytes) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
String hexDigest = hexString.toString();
// Convert to Base64 representation
String base64Digest = Base64.getEncoder().encodeToString(hashBytes);
// Output results
System.out.println("Message: " + message);
System.out.println("SHA-224 hash (hex): " + hexDigest);
System.out.println("SHA-224 hash (Base64): " + base64Digest);
System.out.println("Hash length in bits: " + (hashBytes.length * 8));
System.out.println("Hash length in bytes: " + hashBytes.length);
System.out.println("Hex string length: " + hexDigest.length());
System.out.println("Base64 string length: " + base64Digest.length());
}
}
Security Implications of SHA-224 Length
The 224-bit output length of SHA-224 has important security implications:
Collision Resistance
SHA-224 provides 112 bits of security against collision attacks (finding two different inputs that produce the same hash). This means an attacker would need approximately 2112 operations to find a collision with a 50% probability.
Preimage Resistance
SHA-224 provides 224 bits of security against preimage attacks (finding an input that produces a given hash). This requires approximately 2224 operations, which is computationally infeasible.
Birthday Attack Resistance
The birthday paradox means that collision resistance is approximately the square root of the output size. For SHA-224, this is 2112, which is still considered secure for most applications.
Quantum Computing Implications
Quantum computers using Grover's algorithm could potentially find preimages with complexity of 2112 operations, but this still maintains an adequate security margin for most applications.
Security Considerations
When choosing between SHA-224 and SHA-256:
- SHA-224 (112-bit security) is appropriate for most applications that don't require post-quantum security margins
- SHA-256 (128-bit security) offers additional security margin at the cost of slightly larger hashes
- For long-term security (beyond 2030), consider SHA-256 or stronger hash functions
- SHA-224 is suitable for applications that need to match 112-bit symmetric security levels
Applications Leveraging SHA-224 Length
The specific 224-bit length of SHA-224 makes it particularly well-suited for certain applications:
TLS/SSL Certificates
SHA-224 is used in certificate signing to match 112-bit symmetric encryption security levels, offering a good balance between security and processing efficiency.
Digital Signatures
The 224-bit length works well with ECDSA signatures using P-224 curves, creating a consistent security profile across the entire digital signature system.
Embedded Systems
In constrained environments, the 12.5% reduction in size compared to SHA-256 can be meaningful for bandwidth or storage savings while maintaining adequate security.
Legacy System Integration
Some systems designed for 224-bit output sizes can directly utilize SHA-224 without modifications or truncation that might be needed for other hash functions.
Perfect Size Match
224 bits exactly matches the output size requirements of certain cryptographic protocols and standards designed with this specific security level in mind.
Bandwidth-Optimized Applications
IoT and mobile applications that need to minimize data transmission can benefit from using SHA-224 instead of SHA-256 when the security level is appropriate.
Frequently Asked Questions About SHA-224 Length
Why is SHA-224 exactly 224 bits long?
SHA-224 was designed to provide 112 bits of security against collision attacks, making it suitable for systems using 112-bit symmetric encryption. The 224-bit output is derived from the SHA-256 algorithm by using different initialization values and truncating the final hash state to 224 bits (the first 7 of 8 32-bit words).
Is the 224-bit length of SHA-224 secure enough?
Yes, for most applications. A 224-bit hash provides 112 bits of collision resistance, requiring approximately 2112 operations to find a collision. This is well beyond current computational capabilities. For comparison, breaking a 112-bit symmetric key would require similar effort.
Why use SHA-224 instead of truncating SHA-256?
While you could truncate SHA-256 to 224 bits, SHA-224 uses different initialization values that make its output cryptographically distinct. This ensures that SHA-224 is a separate, standardized algorithm with its own security analysis and properties, rather than an ad-hoc truncation.
How many characters is a SHA-224 hash?
A SHA-224 hash is typically represented as a 56-character hexadecimal string. Each hexadecimal character represents 4 bits, so 56 characters × 4 bits = 224 bits. In Base64 encoding, it would be 38 characters (including padding).
Does SHA-224 always produce exactly 224 bits?
Yes, SHA-224 always produces exactly 224 bits (28 bytes) regardless of the input size. This fixed-length output is a fundamental property of cryptographic hash functions and ensures consistency across all implementations and use cases.
Can I convert between different representations of the 224-bit hash?
Yes, you can convert between hexadecimal, Base64, binary, and raw byte representations without changing the underlying 224-bit hash value. Various programming languages provide functions to convert between these formats while preserving the 224-bit value.
SHA-224 Hash Length Calculator
Use our tool to calculate a SHA-224 hash and see its various representations:
Hash Representations
- Bits: 224
- Bytes: 28
- Hex characters: 56
- Base64 characters: 38 (with padding)