如何在javascript中加密数据并在php中解密?

2021-12-20 00:00:00 encryption security php javascript

是否有任何可以加密数据的 javascript 函数:例如,我想在我的 ajax GET 请求传递的 URL 中使用加密数据,

Is there any javascript function that can encrypt data: For example i want to use encrypted data in my URL passed by ajax GET request,

http://sample.com/mypage/TDjsavbuydksabjcbhgy

其中 TDjsavbuydksabjcbhgy 相当于 12345 的加密数据.现在我想通过解密来检索 PHP 中的数据,以便我可以使用 12345.

where TDjsavbuydksabjcbhgy an encrypted data equivalent to 12345. Now i want to retrieve that data in PHP by decrypting it, so that i can use the 12345.

有可能吗?或任何关于如何做到这一点的建议.

Is it possible? or any suggestion on how to do that.

提前致谢.

推荐答案

我不确定在 javascript 中进行加密会获得什么.您的整个例程和加密密钥对公众有效.如果您要防止嗅探,则应使用 SSL.

I'm not sure what you would gain by doing encryption in javascript. Your entire routine and encryption key are effectively available to the public. If you are trying to protect against sniffing, you should use SSL.

相关文章