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中?
你这是加密、又不是哈希。
加密必然可解密,互为逆运算。
初中数学的函数与映射知识。