Hash Functions

Cryptographic hash functions for data integrity, digital signatures, and content addressing.

Available Hash Functions

BLAKE3

Recommended - Fastest modern hash function

  • 256-bit security
  • Parallel hashing support
  • Extendable output
  • Keyed hashing (MAC mode)
  • Key derivation (KDF mode)

BLAKE2b / BLAKE2s

High-speed hash functions (RFC 7693)

  • BLAKE2b: optimised for 64-bit (up to 512-bit output)
  • BLAKE2s: optimised for 32-bit (up to 256-bit output)
  • Built-in keyed mode (MAC without HMAC)
  • Faster than MD5/SHA-1/SHA-2

SHA-256

Standard hash function, widely supported

  • 256-bit security
  • FIPS 180-4 compliant
  • Hardware acceleration (SHA-NI)

SHA-512

Large output hash function

  • 512-bit output
  • 256-bit security
  • Faster than SHA-256 on 64-bit systems

SHA-3

NIST standard based on Keccak

  • Multiple output sizes (224, 256, 384, 512)
  • Different construction than SHA-2
  • FIPS 202 compliant

Legacy Hash Functions

⚠️
These hash functions are cryptographically broken. Only use for legacy system compatibility or non-security checksums. For new applications, use SHA-256, SHA-3, or BLAKE3.

SHA-1 ⚠️ Deprecated

Cryptographically broken since 2017

  • 160-bit output
  • Collision attacks demonstrated (SHAttered)
  • Only for legacy compatibility

MD5 ⚠️ Broken

Completely broken since 2004

  • 128-bit output
  • Collisions in seconds on modern hardware
  • In Weak:: namespace
  • Never use for security

Common Interface

All hash functions share a common interface:

class HashFunction {
public:
    // Get algorithm name
    std::string AlgorithmName() const;

    // Get digest size
    unsigned int DigestSize() const;

    // Update hash with data
    void Update(const byte* input, size_t length);

    // Finalize and get result
    void TruncatedFinal(byte* digest, size_t digestSize);

    // Reset to initial state
    void Restart();
};

Quick Reference

AlgorithmOutput SizeSecuritySpeedStatus
BLAKE332 bytes (extendable)256-bit⚡⚡⚡⚡⚡Recommended
BLAKE2b64 bytes (configurable)256-bit⚡⚡⚡⚡RFC 7693
BLAKE2s32 bytes (configurable)128-bit⚡⚡⚡⚡RFC 7693
SHA-25632 bytes256-bit⚡⚡⚡⚡Standard
SHA-51264 bytes256-bit⚡⚡⚡⚡Standard
SHA-3-25632 bytes256-bit⚡⚡⚡Standard
SHA-120 bytes❌ Broken⚡⚡⚡⚡Legacy only
MD516 bytes❌ Broken⚡⚡⚡⚡⚡Legacy only

See Also