🔐

Crypto & Hashing Cheatsheet

SHA, MD5, HMAC output sizes, AES key lengths, bcrypt cost factor reference.

Hash Algorithm Reference

AlgorithmOutput SizeHex CharsSecurity Status
MD5128-bit32Broken — collision attacks exist. Do not use for security.
SHA-1160-bit40Deprecated — collision demonstrated in 2017. Avoid.
SHA-256256-bit64Secure — recommended for general use.
SHA-384384-bit96Secure — higher security margin.
SHA-512512-bit128Secure — highest standard SHA-2 variant.
SHA3-256256-bit64Secure — Keccak-based, independent of SHA-2.
BLAKE2b512-bit (max)128Secure — faster than SHA-2 in software.

bcrypt Reference

PropertyValue
Output length60 characters
Output format$2b$[cost]$[22-char salt][31-char hash]
Salt length128 bits (22 base-64 chars)
Cost factor 10~100ms on modern hardware — recommended minimum
Cost factor 12~400ms — recommended for high-security apps
Cost factor 14~1.5s — high-security, low-volume
Max password length72 bytes (bcrypt truncates beyond this)

AES Key Sizes

VariantKey SizeRoundsUse Case
AES-128128-bit (16 bytes)10General-purpose, fast, NIST approved
AES-192192-bit (24 bytes)12Rarely used — middle ground
AES-256256-bit (32 bytes)14High-security, TLS 1.3, recommended

Always use authenticated encryption (AES-GCM) rather than AES-CBC without authentication.

HMAC Quick Reference

HMAC VariantOutput LengthCommon Use
HMAC-MD5128-bitLegacy; avoid for security
HMAC-SHA1160-bitOAuth 1.0a (legacy); avoid where possible
HMAC-SHA256256-bitJWT HS256, webhook signatures, API auth
HMAC-SHA512512-bitHigh-security signing, JWT HS512
← All Cheatsheets