How to encrypt a POST via Ajax

Asked

Viewed 974 times

-1

How do I encrypt the posts I send via Ajax? For example in Telegram Web they do this, you can see by XHR with the requests sent and received.

Example of how it is in Telegram Web (I wish my application to be like this too): inserir a descrição da imagem aqui

Ps: I am developing with Javascript and PHP.

  • can use functions like crypt() http://php.net/crypt

  • This request is not being made under https ?

  • I don’t know. I wanted a practical example to see how it works!

1 answer

2


One way to do this is to use the jCryption library (http://www.jcryption.org/).

As the example of their page, the browser would send the following request.

POST

http://www.jcryption.org/jcryption.php?jCryption=U2FsdGVkX19Zw/DbJFLurww7uudVpt/sdgTx7ezKlLsxrx82sfFwdaZw7oT9a4Feu0EzKZ7w+yX7UC+R5K2wh/6Kwpt08yQ2K00yP+a2EnE=

HTTP/1.1

And on the server would arrive the data as expected.

"email=john%40smith.com&password=1234&role=Admin&remember=on"
  • Thanks, man this will help me a lot.

  • As for the answer of the college "P. R. Ribeiro": Because it is an opensource library, encryption is not easy to break no?

Browser other questions tagged

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