Hashing
MD5, SHA, bcrypt.
What Is a Hash?
A hash function takes input of any size and produces a fixed-size output called a digest. The same input always produces the same digest.
Crucially, hashing is a one-way operation. You cannot mathematically reverse a digest back into the original input. This is what makes hashes different from both encoding and encryption.
Properties of a Good Hash
A cryptographic hash function should be:
- Deterministic: same input gives same output.
- Fast to compute (for general hashing) but ideally slow for password hashing.
- Preimage resistant: given a digest, you cannot find the input.
- Collision resistant: hard to find two inputs with the same digest.
- Avalanche effect: one bit change flips about half the output bits.