Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
postman returns status code 401 even though my hashedpwd and decrypted pwd are identical
router.post("/login", async (req, res) => {
  try {
    const user = await User.findOne({ email: req.body.email });
    if (!user) return res.status(401).json("Wrong Credentials!");
    var salt = process.env.SALT; //SALT
    var hashedPassword = CryptoJS.PBKDF2(req.body.masterPassword, salt, {
      //HASHED PWD
      keySize: 256 / 32,
    });
    const decryptedPassword = CryptoJS.AES.decrypt(
      user.masterPassword,
      process.env.PASS_SEC
    ).toString();
    console.log(decryptedPassword+" "+hashedPassword)

    if (hashedPassword === decryptedPassword) {
      res.status(200).json(user);
    } else {
      res.status(401).json("pwd dont match!");
    }
  } catch (err) {
    res.status(500).json(err);
  }
});

console.log(decryptedPassword+" "+hashedPassword) returns 8da9d88c32a0246a66ed3a70b8e3a9c34d46112ebb3b2e891172e5773bfa80dd 8da9d88c32a0246a66ed3a70b8e3a9c34d46112ebb3b2e891172e5773bfa80dd

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!