Cryptographic hash functions are a basic building block of cryptography. They have three very important properties:
- Pre-image resistance. Given a value h, it is hard to find a message m such that hash(m)=h.
- Second pre-image resistance. Given a message m1, it is hard to find a second message m2 such that hash(m1)=hash(m2).
- Collision resistance. It is hard to find a pair of messages (m1, m2) such that hash(m1)=hash(m2).
Cryptographic hash functions have a lifetime of about 10-20 years before they are broken. Of the hash algorithms you typically see in common APIs, MD4, MD5, and now even SHA-1 are broken. The SHA-2 and SHA-3 family are still considered secure.....for now.
Many security protocols such as TLS and SSH include an algorithm negotiation phase where the client and server mutually agree which cryptographic functions to use. Crypto agility is vital for long-term security.