Use this when using hash functions correctly.
Hash Function
A hash function maps any input to a fixed-size digest. A cryptographic one is one-way, collision-resistant and changes completely when the input changes by one bit.
1. A hash function maps input to fixed-size output.
2. One-way and collision-resistant (cryptographic).
3. Small input change → completely different output.
4. Not encryption.
5. Choose modern algorithms.
input → hash → digest
Context & applicabilityCommon mistakes · platform/version boundaries
- Treating a hash as encryption — it cannot be reversed, but short inputs (phone numbers, CPR numbers) can be brute-forced.
- Assuming hashes show who created a file (use signatures).
- Comparing hashes visually by the first few characters only.
Operational reference
Fast context before you go deeper.
Get-FileHash file.iso -Algorithm SHA256Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- A hash is one-way and fixed length.
- A tiny input change gives a different hash.
- Hashing is not encryption.
sha256sum file— digest- Properties: preimage, second-preimage, collision resistance — security goals
- Algorithm choice — SHA-2/3, BLAKE2/3
ReferenceWhy it matters1 section · depth on demand
Properties and uses
A cryptographic hash must be:
- Pre-image resistant: from a digest you cannot find the input.
- Second pre-image resistant: you cannot find another input with the same digest as a given one.
- Collision resistant: you cannot find any two inputs with the same digest.
| Use | Algorithm |
|---|---|
| File integrity, signatures, certificates | SHA-256, SHA-384, SHA-3 |
| Message authentication | HMAC-SHA-256 |
| Password storage | Argon2id, scrypt, bcrypt (never a plain fast hash) |
sha256sum file (Linux) or Get-FileHash file -Algorithm SHA256 (PowerShell) computes a file hash.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
A hash function maps input data of any size to a fixed-size output. Cryptographic hash functions add security properties — preimage, second-preimage and collision resistance — that make them suitable for integrity checks and signatures; non-cryptographic hashes (CRC32, MurmurHash) are only for error detection and data structures.
| Property | Meaning |
|---|---|
| Deterministic | Same input → same output |
| Avalanche effect | Small change → completely different digest |
| Preimage resistance | Cannot find input from digest |
| Second-preimage resistance | Cannot find another input with the same digest as a given input |
| Collision resistance | Cannot find any two inputs with the same digest |
Use SHA-256 or stronger for security purposes; use dedicated password hashing functions for passwords.
ReferenceConfiguration & state1 section · depth on demand
Commands
sha256sum file.iso # Linux
Get-FileHash file.iso -Algorithm SHA256 # PowerShell
certutil -hashfile file.iso SHA256 # Windows cmd
openssl dgst -sha256 file.iso
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Hashing → Hash Function. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://csrc.nist.gov/pubs/fips/180-4/upd1/final · confidence 94%