Is it possible to decrypt an MD5-encrypted password in PHP?
MD5 encryption is a one-way hashing algorithm, meaning it is not possible to decrypt the hashed password back to its original form. However, you can compare a user-input password with the MD5-encrypted password by hashing the user input and comparing it to the stored hash.
$storedPassword = '5f4dcc3b5aa765d61d8327deb882cf99'; // MD5-encrypted password
$userInput = 'password123'; // User input password
$userInputHash = md5($userInput);
if($userInputHash === $storedPassword) {
echo 'Passwords match!';
} else {
echo 'Passwords do not match.';
}
Keywords
Related Questions
- What are the recommended methods for handling user input validation and sanitization in PHP to prevent SQL injection vulnerabilities?
- What best practices should PHP developers follow when handling LDAP search results in their code?
- In the provided PHP code, what are the implications of not initializing the $id variable before using it in conditional statements?