I’m trying to build an user login/authentication client for a RESTful webservice created by me.
However, while trying to setup authentication using the authentication API’s available JAX-RS, I had some troubles and decided to change the approach. Now, what I’m actually trying to do is:
The webpage sends an ajax POST request to an uri (user/login) contained with his email and his password separated by an “:” symbol. This message body will then be encrypted using the RSA algorithm in the client using some JavaScript lib and decrypted on the server side.
The problem is: I used Java to generate the PublicKey, and they are stored as an base64 string, encoded using X509 padding.
How can I decode this encoded string, which represents the Public Key, using only JavaScript, and actually use it to encrypt some text?
thanks in advance!
Why do you want to encrypt just message body? Just make your AJAX request over SSL – your whole transmission will be encrypted.
This will require only minimal changes in your code (put
httpsin front of url) and you don’t have to worry about encryption in javascript.