pass secure data to jquery from php
I have a token variable that I get with php and write to a div using the data-value parameter so that jquery can get it. I do not want users to see so I was wondering if it was possibl开发者_Go百科e to
- Hide this data on the way to jquery (in the data-value parameter)
- Encrypt the data in Jquery so when the header or sent parameters are displayed, token is encrypted or not visible
var token=$('#token').attr('data-value');
$.ajax({
type: "POST",
data: "action=edit&token=" + token,
url: "doc.php",
dataType: 'json',
success: function(response, statusText)
It's not really possible to do this in any way that's going to be secure against a determined user who really wants to see that token.
This post sounds similar:
Obfuscating POST variables between Javascript & PHP
There is no way known to me hiding a parameter. You can mess with almost all request data by using a debugging proxy like "Fiddler".
The only way to secure data between a web client and a server is to encrypt the channel by using SSL. Anything that the client needs to read in order to use (i.e. anything manipulated in javascript) is going to be visible to a determined user.
If there is some secret data that not even the user should see, it needs to be handled entirely on the server side without ever sending that data to the browser.
精彩评论