Good follow-up questions, Charlie!
Collisions: The Birthday Paradox explains why collisions are inevitable. With a large enough number of inputs, you're statistically likely to find two inputs that hash to the same value. The goal of a *cryptographic* hash function is to make finding such a collision computationally infeasible (taking an astronomical amount of time and resources). If a collision is found for a widely used hash algorithm, it's a serious security vulnerability. This is why older algorithms like MD5 and SHA-1 are no longer considered secure for most applications because collisions have been demonstrated.
Secure Algorithms: Currently, algorithms like SHA-256, SHA-384, SHA-512 (collectively known as SHA-2) and the newer SHA-3 family are considered strong and collision-resistant.
Password Recovery: No, you cannot "recover" a forgotten password from its hash. Because of pre-image resistance, you can't reverse the hash. This is by design for security. If you forget your password, you typically have to go through a password reset process, which usually involves verifying your identity through email or other means and then setting a *new* password. The system doesn't retrieve your old one; it lets you create a new one, which is then hashed and stored.
Salting: To further enhance password security and protect against rainbow table attacks (pre-computed hashes), passwords are often "salted." A unique, random string (the salt) is generated for each password and appended to the password *before* hashing. This means even if two users have the same password, their stored hashes will be different because their salts are different. The salt is stored alongside the hash, making it easy to re-hash the password during login attempts.