How it works...

Nowhere in the code did we decrypt the password. In fact, the password is never stored anywhere. We always worked with the hash of the password. Here are the important points to take away from this recipe:

When we look at the user access table, the correct way to store user credentials would look something like this:

The salt and hash are stored alongside the username, and are secure because they can't be decrypted to expose the actual password.

If you sign up for a service on the Internet and they send you a confirmation either via e-mail or text message and display your password in this message in plain text, then you should seriously consider closing your account. If a system can read your password and send it to you in plain text, so can anybody else. Never use the same password for all your logins.