Skip to content
Advertisement

How to encrypt data in javascript and decrypt in php?

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

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.

Thanks in advance.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement