What Is a Hash Function? Cryptographic Hashing Explained
A cryptographic hash function transforms any input into a fixed-length output. This guide explains what makes a hash function secure, what it is used for, and the difference between hashing and encryption.
ProfitTool Team
Security & Dev
What a Hash Function Does
A cryptographic hash function takes an input of any size and produces a fixed-length output (the hash or digest). The same input always produces the same output, but the output reveals nothing useful about the input.
SHA-256("hello") → 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
SHA-256("Hello") → 185f8db32921bd46d35fa8c84e89ef2b8a21ed2a3c14f3c5a3f0b4f3e35a2e7A single character change produces a completely different hash — this is called the avalanche effect.
Properties of a Cryptographic Hash Function
1. Pre-image resistance (one-way)
Given a hash H, it is computationally infeasible to find any input M such that hash(M) = H.
2. Second pre-image resistance
Given an input M1, it is infeasible to find a different input M2 such that hash(M1) = hash(M2).
3. Collision resistance
It is infeasible to find any two different inputs M1 and M2 that produce the same hash.
Hashing vs Encryption
| Property | Hashing | Encryption |
|---|---|---|
| Reversible | No | Yes (with key) |
| Fixed output length | Yes | Variable |
| Key required | No | Yes |
| Use case | Integrity, passwords | Confidentiality |
Hashing is one-way by design. You cannot "unhash" a value — you can only compare hashes. Encryption is reversible — the ciphertext can be decrypted with the correct key.
Common Uses
Data integrity
File checksums verify a download was not corrupted or tampered with. If the downloaded file's SHA-256 matches the publisher's published hash, the file is intact.
Password storage
Servers store the hash of passwords, not the passwords themselves. At login, the submitted password is hashed and compared to the stored hash.
Digital signatures
A message is hashed, then the hash is signed with a private key. Verifiers hash the message independently and verify the signature against the hash.
Blockchain
Each block in a blockchain includes the hash of the previous block. Altering any block invalidates all subsequent hashes.
Currently Recommended Algorithms
- SHA-256 / SHA-512: standard for data integrity and signatures
- SHA-3: alternative design lineage if SHA-2 weaknesses emerge
- BLAKE3: faster than SHA-256, used in high-performance scenarios
Compute hashes of any text with our Hash Generator and identify unknown hashes with our Hash Type Identifier.
ProfitTool Team
Security & DevWritten and maintained by the ProfitTool team. Where an article references a ProfitTool utility, the behaviour described is the behaviour of the tool on this site — you can open it and check the output yourself.
More from the Knowledge Hub
How to Identify a Hash Algorithm from a Hash String
Length and character set narrow an unknown hash down fast. How to tell MD5 from SHA-256, and how to spot bcrypt, Argon2 and NTLM from their prefixes.
Developer ToolsSHA-256 vs SHA-512: Which Hash Algorithm Should You Use?
Both are SHA-2 and both are secure — the difference is digest size and word width. Why SHA-512 is often faster on 64-bit CPUs, and which to pick.
Privacy & SecurityPassword Hashing Algorithms: bcrypt, Argon2 and PBKDF2 Compared
Passwords should never be stored in plain text or with fast hash functions like MD5 or SHA-256. This guide explains why slow, purpose-built password hashing algorithms are essential and how to choose one.