Skip to content
PHP Logo

What are the potential security risks of using md5 for hashing passwords in PHP?

Using md5 for hashing passwords in PHP is not recommended due to its vulnerability to collision attacks, where two different inputs can produce the same hash. This could allow attackers to easily crack hashed passwords. To improve security, it's better to use stronger hashing algorithms like bcrypt or Argon2.

php
// Use bcrypt for hashing passwords
$hashed_password = password_hash($password, PASSWORD_BCRYPT);