One rule
Never store a user’s password. Store a slow password hash created by a trusted library.
A password hash is one-way. During login, you hash-check the typed password against the stored hash.
Why slow hashes
Normal hashes like SHA-256 are too fast for passwords. If your database leaks, an attacker can try crores of guesses quickly.
Password hash functions like bcrypt and Argon2 are built to be slow. They also include a unique salt so two users with the same password get different hashes.