Skip to content Skip to sidebar Skip to footer

Encrypt String In Javascript And Decrypt In Php With Rsa Technique

I am trying to encrypt some text in JavaScript and then send it to PHP (etc: with Ajax) to decrypt it there and save it (etc: In MySQL). Here is my code so far: In JavaScript: I am

Solution 1:

Use HTTPS.

What you are doing will never be able to protect you against active attacks (MitM) since you don't have any trust anchors, and it is very likely that you will make some stupid mistake that will make it insecure.

Either way, you cannot encrypt more than a few hundred bytes directly with RSA. Thus, you will have to securely generate a random symmetric key (doing that properly in JavaScript is not easy), encrypt the data with it using a secure symmetric cipher (e.g. AES) in a secure block cipher mode, then encrypt the symmetric key with RSA. Learning how to do it "properly" will take you much more time than really doing it properly, and that is, configuring SSL.

Post a Comment for "Encrypt String In Javascript And Decrypt In Php With Rsa Technique"