I want to encrypt some vars in js code and pass them to server side (Python). How can I implement this? Thanks in advance!
-
Well, there are some sensitive information that needs to be encrypted. Or should I pass already encrypted code to client side?sher– sher2011-06-10 09:06:12 +00:00Commented Jun 10, 2011 at 9:06
-
1Use transport layer encryption (i.e. SSL).MattH– MattH2011-06-10 09:28:29 +00:00Commented Jun 10, 2011 at 9:28
2 Answers
Activate HTTPS on your server and all communication between the browser and your server will be encrypted, and you won't need to do any additional work in your code.
How you do this depends on what webserver you're using.
Comments
HTTPS is definitely the way to go. However, if for whatever reason HTTPS is unavailable (e.g., you're on google app engine with a custom domain), you can try jCryption on the front-end and pyCrypto on the server.
An advantage is that you do not need to buy an SSL certificate or deal with certificate administration. A disadvantage (and it's a big one) is that it is very easy to get encryption wrong and expose your site to security vulnerabilities. Also, without a certificate your site is still vulnerable to certain types of attacks. So make sure you know how the encryption works and proceed with caution.