Junior — Middle
How is data compliance checked after login and password input?
sobes.tech AI
Answer from AI
Verification of data after entering login and password usually occurs as follows:
- The user enters login and password.
- The application receives this data and searches for the user in the database by login.
- If the user is found, the entered password is compared with the stored password.
Important: passwords in the database are usually stored as hashes (for example, using bcrypt, PBKDF2, Argon2 algorithms). Therefore, the check proceeds as follows:
- The entered password is hashed with the same algorithm and parameters.
- The resulting hash is compared with the stored hash.
If the hashes match — the user is authenticated.
Example in Java (simplified):
String inputPassword = ...; // password entered by the user
String storedHash = getPasswordHashFromDB(login);
boolean matches = PasswordHasher.verify(inputPassword, storedHash);
if (matches) {
// successful login
} else {
// authentication error
}
Where PasswordHasher.verify is a method that implements password verification considering salt and hashing algorithm.