0 votes
in NodeJS Essentials by
What is password hashing?

1 Answer

0 votes
by

hash("hello") = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 hash("hbllo") = 58756879c05c68dfac9866712fad6a93f8146f337a69afe7dd238f3364946366 hash("waltz") = c0e81794384491161f1777c232bc6bd9ec38f616560b120fda8e90f383853542

Hash algorithms are one way functions. They turn any amount of data into a fixed-length "fingerprint" that cannot be reversed. They also have the property that if the input changes by even a tiny bit, the resulting hash is completely different (see the example above). This is great for protecting passwords, because we want to store passwords in a form that protects them even if the password file itself is compromised, but at the same time, we need to be able to verify that a user's password is correct.

The general workflow for account registration and authentication in a hash-based account system is as follows:

1. The user creates an account.

2. Their password is hashed and stored in the database. At no point is the plain-text (unencrypted) password ever written to the hard drive.

3. When the user attempts to login, the hash of the password they entered is checked against the hash of their real password (retrieved from the database).

4. If the hashes match, the user is granted access. If not, the user is told they entered invalid login credentials.

5. Steps 3 and 4 repeat every time someone tries to login to their account.

Related questions

0 votes
0 votes
asked Feb 16, 2022 in Digital Malware Analysis by sharadyadav1986
+2 votes
asked Sep 10, 2020 in Cyber Security by Hodge
...