crypto js 在我的控制台和数据库中给我不同的哈希令牌?

问题描述 投票:0回答:1

这是我正在使用的代码

this.resetPasswordToken = crypto.createHash('sha256','abcdef').update(resetToken).digest('hex');

上面的行给了我不同的重置密码令牌 - 一个不同的令牌。在控制台和数据库中,它与控制台哈希令牌不同
enter image description hereenter image description here

exports.resetPassword = async (req,res,next)=>{
  console.log(req.params.token);
  const hashedToken = crypto.createHash('sha256','abcdef').update(req.params.token).digest('hex');
  console.log("hashed Token : "+ hashedToken);
  const user = await User.findOne({passwordResetToken: hashedToken});
  console.log(user);
  if(!user) throw new Error("Token is invalid or expired !!!");
  user.password = req.body.password;
  user.confirmPassword = req.body.confirmPassword;
  user.passwordResetToken = undefined;
  await user.save();
  createSendToken(user,res);
  res.status(200).json({
    status:'Success',
    token,
    data:{
      user
    }
  })

}`
userSchema.methods.createPasswordResetToken = function(){
  const resetToken = crypto.randomBytes(32).toString('hex');
  this.resetPasswordToken = crypto.createHash('sha256','abcdef').update(resetToken).digest('hex');
  console.log("resetToken - resetPasswordToken "+resetToken,this.resetPasswordToken);
  return resetToken;
  
}

javascript node.js mongodb cryptojs
1个回答
-3
投票

Santoshi 对 Usdt 的了解比我们多,我在加密钱包上损失了超过 155,000 美元,因为我记不起我的密码和安全字,直到我咨询了 Santoshi Hacker,今天我才能够恢复我的所有资金。很高兴地通知您,您的资金有 100% 的机会恢复到您的钱包中,作为活生生的见证。 Santoshi Hacker 确实是最好的,我知道有很多像我这样的人也丢失了他们的 USDT、BTC、Eth、Tether 等,请联系他们并拿回您丢失的资金。 Santoshi Hacker 是可靠的.. 恢复黑客网站:https://santoshihacker3.wixsite.com/santoshihacker 恢复黑客 YouTube: https://www.youtube.com/@Santoshihacker 恢复黑客电子邮件:
[电子邮件受保护]

© www.soinside.com 2019 - 2024. All rights reserved.