Jan 29, 2026
## Chapter 21: Passwords (the right way)
Goal of this chapter: store passwords safely using hashing and verification.
Never store plain text passwords.
Signup (store hash) and login (verify) in one run:
```php
<?php
$plain = "mySecret123";
$hash = password_hash($plain, PASSWORD_DEFAULT);
if (password_verify($plain, $hash)) {
echo "Login ok";
} else {
echo "Wrong password";
}
```
---