Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

function encode(data) {
  const cipher = crypto.createCipher('aes192', pass);
  let crypted = cipher.update(data, 'utf-8', 'hex');
  crypted += cipher.final('hex');
  return crypted;
}

这是加密的代码, 如果用固定的pass(pass存在于后端),把crypted作为cookie返回给用户,用户也知道加密的data,能否反解出pass

如果能的话,是不是最好不是固定的pass,每个用户不同的pass存在mysql的user table中?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
412 views
Welcome To Ask or Share your Answers For Others

1 Answer

你这是加密、又不是哈希。

加密必然可解密,互为逆运算。

初中数学的函数与映射知识。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...