Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
406 views
in Technique[技术] by (71.8m points)

crypto用固定密码加密unionId, 知道unionId与加密后的信息能反解出密码吗?

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中?


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

1 Answer

0 votes
by (71.8m points)

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

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...