Created
August 14, 2020 02:28
-
-
Save parzibyte/7e91a789811e3123c0218b9e428199aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Importamos paquete | |
const bcrypt = require("bcryptjs"); | |
// Este hash debe venir de tu base de datos, por ejemplo | |
// Nota: yo sé que este hash es "hunter2", obviamente es para ejemplificar | |
const palabraSecretaHasheada = "$2a$10$P9yvh9ew5ZueNRjQGX4Eiui9jNhaKJCX24mRsrWSNvj.0O2FjNSB2"; | |
const palabraSecretaProporcionadaPorUsuario = "hunter2"; | |
// Recuerda. Los argumentos son: texto plano, encriptada, y callback | |
bcrypt.compare(palabraSecretaProporcionadaPorUsuario, palabraSecretaHasheada, (err, coinciden) => { | |
if (err) { | |
console.log("Error comprobando:", err); | |
} else { | |
console.log("¿La contraseña coincide?: " + coinciden); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment