For your learning purpose, simply compare strings. If your userInputPassword is in plain text and password stored in admin.txt is hashed, then you have to decrypt your password in admin.txt before comparing.
const fs = require('fs');
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
const read = fs.readFileSync('admin.txt', 'utf8');
console.log(read);
readline.question(`What's your email? `, (email) => {
const userInputEmail = email.trim();
console.log(`Email: ${email}`)
readline.question(`What's your password? `, (password) => {
const userInputPassword = password.trim();
console.log(`Password: ${password}`);
const [correctEmail, correctPassword] = read.split('\n').map(s => s.trim());
if (userInputEmail === correctEmail && userInputPassword === correctPassword) console.log('Logged in');
else console.log('Email or password is incorrect');
readline.close();
});
});
[email protected]and the passwordadmin. And the answer from Nguyễn Việt Đức that you said was "Awesome" reads the password out of the file in plain text. You're right that so far it does not make sense to me.