I recently encountered the need to use js to transfer three values to another page without allowing the parameters to be displayed directly in the URL. It needs to be encrypted. How to deal with it?
I recently encountered the need to use js to transfer three values to another page without allowing the parameters to be displayed directly in the URL. It needs to be encrypted. How to deal with it?
Commonly used PHP functions urlencode
and urldecode
are here. There are also base64_encode
and base64_decode
, which are mostly used for image encryption. Here is a link for your reference: Several commonly used encryption functions in PHP
Use post?
If you don’t want to display it behind the url, then use the post method of the form;
If you just want to ‘encrypt’ it, you can encodeURIComponent;
If you just encrypt it, you can use Base64.encode64 to decrypt Base64.decode64
If you just want to prevent passers-by from seeing it,
@hit水ヽ’s base64_encode is a better way.
base64 is just encoding, because no one can decode it verbally...
You can consider packaging the three values into json, and then base64 encoding the json string.
If it is a jump from one web service A to another web service B, A and B want to communicate through this encryption.
You can consider referring to the encryption scheme of WeChat Enterprise Account.
In fact, both A and B know a set of secret keys, and then A uses the secret key to encrypt the message, converts it to base64, puts it in the query, and passes it to B.
p.s. Can I complain about style=original
...
The poster probably doesn’t want others to know the parameters, right? Then encodeURIComponent and the like will definitely not work, it is just encoding.
base64 is not strictly speaking encryption.
RSA?