How does the use of SHA enhance password security compared to MD5 in PHP?
Using SHA instead of MD5 enhances password security because SHA generates a more secure hash compared to MD5. SHA algorithms have longer hash values and are less prone to collisions, making it harder for attackers to crack passwords using brute force or rainbow table attacks.
// Using SHA-256 to hash passwords in PHP
$password = "password123";
$hashed_password = hash('sha256', $password);
Related Questions
- What are some best practices for debugging PHP code that involves database operations and PDF generation?
- What are the best practices for using PDO in PHP to handle database queries and updates more efficiently?
- What strategies can be implemented to ensure the proper execution of PHP switch case statements when dealing with user input?