> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# SHA256 Comparison

> Comparing SHA-256 with other hash functions

<Card title="Try it Live" icon="play" href="https://playground.tevm.sh?example=crypto/sha256.ts">
  Run SHA256 examples in the interactive playground
</Card>

<Warning>
  **This page is a placeholder.** All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.
</Warning>

# SHA256 Comparison

How SHA-256 compares to other cryptographic hash functions.

## Quick Comparison Table

| Hash Function | Output Size | Speed     | Security | Use Case                 |
| ------------- | ----------- | --------- | -------- | ------------------------ |
| **SHA-256**   | 32 bytes    | Fast      | 256-bit  | General purpose, Bitcoin |
| Keccak-256    | 32 bytes    | Medium    | 256-bit  | Ethereum                 |
| Blake2b       | 1-64 bytes  | Very Fast | 512-bit  | High performance         |
| RIPEMD-160    | 20 bytes    | Medium    | 160-bit  | Bitcoin addresses        |
| SHA-512       | 64 bytes    | Fast      | 512-bit  | Higher security          |

## SHA-256 vs Keccak-256

**SHA-256:**

* NIST standard (FIPS 180-4)
* Hardware acceleration widely available
* Bitcoin, TLS/SSL, certificates
* 3200 MB/s with SHA-NI

**Keccak-256:**

* SHA-3 variant (original Keccak)
* Used in Ethereum
* Different padding than SHA-3
* 1800 MB/s with optimizations

**When to use SHA-256:**

* Bitcoin applications
* General cryptography
* Regulatory compliance required
* Hardware acceleration important

**When to use Keccak-256:**

* Ethereum smart contracts
* EVM compatibility required
* Address/topic calculation

## SHA-256 vs Blake2

**SHA-256:**

* Older, more established (2001)
* NIST standardized
* Hardware acceleration (SHA-NI)
* 3200 MB/s accelerated, 500 MB/s software

**Blake2:**

* Newer design (2012)
* Faster in software (700 MB/s)
* Variable output length
* Not NIST standardized

**When to use SHA-256:**

* Regulatory compliance needed
* Hardware acceleration available
* Standard conformance required

**When to use Blake2:**

* Maximum software performance
* Variable output length needed
* No compliance requirements

## SHA-256 vs SHA-512

Both are SHA-2 family members.

**SHA-256:**

* 32-byte output
* Optimized for 32-bit platforms
* More common in protocols

**SHA-512:**

* 64-byte output
* Faster on 64-bit platforms
* Higher theoretical security

**Performance (64-bit CPU with acceleration):**

* SHA-256: 3200 MB/s
* SHA-512: 3400 MB/s (slightly faster!)

**When to use SHA-256:**

* Standard 256-bit security sufficient
* Smaller output preferred
* Protocol specifies SHA-256

**When to use SHA-512:**

* 512-bit security required
* 64-bit platform
* Larger output acceptable

## Security Comparison

| Hash        | Collision | Preimage | Status       |
| ----------- | --------- | -------- | ------------ |
| **SHA-256** | 2^128     | 2^256    | ✅ Secure     |
| Keccak-256  | 2^128     | 2^256    | ✅ Secure     |
| Blake2b     | 2^256     | 2^512    | ✅ Secure     |
| SHA-1       | Broken    | 2^160    | ❌ Deprecated |
| MD5         | Broken    | Broken   | ❌ Insecure   |

All modern hash functions (SHA-256, Keccak-256, Blake2) provide adequate security.

## Migration Guide

### From MD5/SHA-1

```typescript theme={null}
// OLD (INSECURE)
import crypto from 'crypto';
const oldHash = crypto.createHash('md5').update(data).digest();

// NEW (SECURE)
import { SHA256 } from '@tevm/voltaire/SHA256';
const newHash = SHA256.hash(data);
```

### Choosing the Right Hash

**Use SHA-256 when:**

* ✅ Bitcoin/blockchain applications
* ✅ Digital signatures
* ✅ Certificate fingerprints
* ✅ Regulatory compliance required
* ✅ Hardware acceleration available

**Use Keccak-256 when:**

* ✅ Ethereum smart contracts
* ✅ EVM compatibility needed

**Use Blake2 when:**

* ✅ Maximum performance in software
* ✅ Variable output length needed
* ✅ No regulatory requirements

## See Also

* [SHA256 Overview](/crypto/sha256)
* [Keccak256](/crypto/keccak256)
* [Blake2](/crypto/blake2)
