What Is a Hash Function?
A cryptographic hash function takes input of any size and produces a fixed-length fingerprint called a digest. It is one-way — you cannot reverse it — and collision-resistant — it is infeasible to find two different inputs that produce the same digest. These properties underpin digital signatures, password storage, file integrity checks, and blockchain.
The One-Line Definition
A cryptographic hash function is a deterministic algorithm that maps an input of arbitrary size to a fixed-length bit string (thedigest) such that any change to the input produces a completely different digest.
Key Properties
A Concrete Example
Hashing the string hello with SHA-256 always produces:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
Changing a single character — Hello (capital H) — produces a completely different digest:
185f8db32921bd46d35cc2e45a25b0e08fb2c0b67a17b4ea4b5c2d77ed1e3a8e
This is the avalanche effect.
Common Hash Algorithms
| Algorithm | Output | Status | When to use |
|---|---|---|---|
| MD5 | 128 bits / 32 hex chars | Broken | Legacy checksums only. Do not use for security. Practical collisions demonstrated. |
| SHA-1 | 160 bits / 40 hex chars | Broken | Deprecated in TLS/certificates since 2017. Git still uses it for content-addressing but is migrating. |
| SHA-256 | 256 bits / 64 hex chars | Secure | Current standard. Used in TLS certificates, git SHA-2 mode, JWT HMAC signing, and blockchain. |
| SHA-512 | 512 bits / 128 hex chars | Secure | Higher security margin than SHA-256. Preferred on 64-bit platforms where it can be faster. |
| SHA-3 | 256 bits / 64 hex chars | Secure | NIST standard (2015) with a different design from SHA-2. Not yet widely adopted in existing protocols. |
| bcrypt | 60 chars | Passwords | Designed specifically for password hashing. Slow by design with a tunable cost factor. Not a general hash. |
Hash Functions Are Not Encryption
Encryption is reversible (with the correct key). Hashing isone-way — there is no key and no decryption. Do not confuse the two. In particular: do not store passwords hashed with SHA-256. Use a purpose-built password hashing function like bcrypt, scrypt, or Argon2, which are intentionally slow and include a salt to prevent rainbow table attacks.
Where Hash Functions Are Used
Generate a Hash Now
Paste any text into SmartDevBox's Hash Generator and get MD5, SHA-1, SHA-256, and SHA-512 digests simultaneously — all computed in the browser using the Web Crypto API. No data is sent to a server. Open the Hash Generator →
Frequently Asked Questions
Can a hash be reversed?
No. A well-designed cryptographic hash function is one-way — there is no algorithm that recovers the original input from the hash alone. Short or common inputs can be "cracked" by brute force or rainbow tables, which is why password hashing uses bcrypt/Argon2 with salts.
What is the difference between MD5, SHA-1, and SHA-256?
MD5 (128-bit) and SHA-1 (160-bit) are cryptographically broken — practical collisions exist. SHA-256 (256-bit) is the current standard for security-sensitive use. Use SHA-256 or SHA-512 for new systems.
What is a hash collision?
Two different inputs producing the same hash output. Theoretically unavoidable (infinite inputs, finite outputs) but should be computationally infeasible for a secure hash function. MD5 and SHA-1 have practical collision attacks.
How do I generate a SHA-256 hash online?
Paste your text into SmartDevBox. The Hash Generator computes MD5, SHA-1, SHA-256, and SHA-512 simultaneously in the browser using the Web Crypto API. No data is sent to a server.