Encrypt JS/PHP GET parameter

Asked

Viewed 509 times

1

What is the best way to traffic data between JS and PHP vie GET method? Imagine a $http request made on Angularjs passing ex parameters: minhaurl? id=2&name="Joao"

The ideal would be to encrypt the parameters. But the BASE64 is flawed in relation to UTF8.

So, how to send data in encrypted form via GET and decrypt in PHP and send the answers encrypted in PHP and decrypt in js?

  • It is mandatory to use the get method?

  • 3

    If you are talking about Base64 security it is not to encrypt and neither any method I know will serve you like this, I believe the way is to use HTTPS.

  • Not really. I could use the POST. But my question is whether it would be possible to make the GET secure. Even if I use the POST, it would still be possible for any personnel to capture the headers and inspect the variables. which makes my application insecure. So independent of GET or POST. How to encrypt and ensure decoding in JS/PHP

  • 2

    To use get safely you would need to use an SSL certificate and use HTTPS. And the safest way is by the post method.

  • JWT still has many flaws ...

  • 1

    Any encryption would be insecure in client side, since it is possible to know which algorithm was used to encrypt. You need data to be encrypted in PHP before rendering HTML - the ID 1 becomes a3d296261dbda886e8685e4bad338bf4

  • 2

    Base64 is not encryption and Base64 has no problem with UTF-8. And there is no point in "encrypting" anything on the JS side, as it can be undone with peace of mind. Even if you send a different key to the JS for each request, whoever intercepts the communication will have access to it. HTTPS is what you can do (and even so, against third parties, because on the client side, everything is accessible).

  • It has some faults yes: http://stackoverflow.com/questions/30106476/using-javascripts-atob-to-decode-base64-doesnt-properly-decode-utf-8-strings

  • Try to encrypt the contents of the data using the Crypto-js: https://github.com/brix/crypto-jslibrary

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.