What Are Hash Functions?
A cryptographic hash function takes an input of any size and produces a fixed-size output (the hash or digest). The function is deterministic — the same input always produces the same hash — and it is designed to be a one-way function, meaning you cannot reverse the hash to recover the original input. Even a tiny change in the input produces a completely different hash, a property known as the avalanche effect.
SHA-256("hello") → 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
SHA-256("hello.") → cee82d1dbbcc12c23e0060a1d1220be1f3413bbc61e4f09a001f0b36e4e36cf4
// One period changes the entire hashHash functions are fundamental to computer science and security. They power digital signatures, password storage, data integrity verification, blockchain technology, and much more.
SHA Algorithm Comparison
The Secure Hash Algorithm (SHA) family includes several variants with different output sizes and security properties:
SHA-1 (160 bits / 40 hex characters)
SHA-1 was widely used for years but is now considered cryptographically broken. In 2017, Google demonstrated a practical collision attack (two different inputs producing the same hash). SHA-1 should not be used for security purposes, but you may still encounter it in legacy systems, Git commit hashes, and older certificate chains.
SHA-1("hello") → aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434dSHA-256 (256 bits / 64 hex characters)
SHA-256 is part of the SHA-2 family and is the most widely used hash algorithm today. It is used in TLS/SSL certificates, Bitcoin mining, code signing, and most modern security applications. No practical attacks against SHA-256 are known.
SHA-256("hello") → 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824SHA-384 and SHA-512 (384/512 bits)
SHA-384 and SHA-512 offer longer hash outputs for applications that need higher security margins. SHA-512 is actually faster than SHA-256 on 64-bit processors because it operates on 64-bit words natively. SHA-384 is a truncated version of SHA-512.
Use Cases for Hashing
File Integrity (Checksums)
Software downloads often include a SHA-256 checksum. After downloading a file, you can hash it locally and compare the result to the published checksum to verify the file was not corrupted or tampered with during transfer:
# On macOS/Linux
shasum -a 256 downloaded-file.zip
# Compare with the published hash
# If they match, the file is intactPassword Storage
Passwords should never be stored in plain text. Instead, they are hashed before storage. When a user logs in, the entered password is hashed and compared to the stored hash. Modern password hashing uses specialized algorithms like bcrypt, scrypt, or Argon2 that are intentionally slow to resist brute-force attacks. Plain SHA-256 is too fast for password hashing — use it for checksums and signatures, not passwords.
Data Integrity and Deduplication
Hashes are used to detect duplicate data without comparing full contents. Cloud storage services, backup systems, and version control systems hash file contents to identify duplicates and detect changes efficiently. If two files produce the same hash, they are (almost certainly) identical.
Digital Signatures
In digital signature schemes, the document is hashed first, and the hash is then signed with a private key. This is more efficient than signing the entire document and produces a fixed-size signature regardless of document size.
How to Use the Hash Generator
The Hash Generator computes hashes instantly in your browser:
- Enter your text in the input area — paste any string you want to hash.
- Select the algorithm — choose from SHA-1, SHA-256, SHA-384, or SHA-512.
- Copy the hash — the result is displayed instantly and can be copied with one click.
Hashing in Code
Most languages provide built-in hashing support:
// JavaScript (Web Crypto API)
const hash = await crypto.subtle.digest(
"SHA-256",
new TextEncoder().encode("hello")
);
const hex = [...new Uint8Array(hash)]
.map(b => b.toString(16).padStart(2, "0"))
.join("");
// Python
import hashlib
hashlib.sha256(b"hello").hexdigest()
// Command line
echo -n "hello" | shasum -a 256When you just need a quick hash without writing code, use the Hash Generator — it is free, runs entirely in your browser, and supports all major SHA algorithms.
