ali*_*990 2 encryption node.js express cryptojs
我正在加密用户 ID,crypto-js通过 url 发送它,如下所示,以便用户在单击时验证它:
http://localhost:3000/api/customer/activate/U2FsdGVkX1DXzzLuf9TgBf31Mc2V/QBVAN05PovlNM
这是加密的用户 ID:
U2FsdGVkX1DXzzLuf9TgBf31Mc2V/QBVAN05PovlNM
使用加密js encrypt:
crypto.AES.encrypt(term.toString(), config.CRYPTO_PASSPHRASE_RES).toString(crypto.enc.Utf8)
Run Code Online (Sandbox Code Playgroud)
当我运行 API 时,它返回route not found,当我/从加密的用户 ID 中删除时,它起作用了。
如何防止 crypto-js 添加/到加密 ID 中?
解决方案是使用encodeURIComponent()然后像decodeURIComponent()下面这样:
encodeURIComponent(crypto.AES.encrypt(term.toString(), config.CRYPTO_PASSPHRASE_RES).toString());
Run Code Online (Sandbox Code Playgroud)
它将替换/成其他东西。