0

I have code like below, now I want to Encrypt variable "encrydata" and same Decrypt in java, is there any choice to encrypt variables.?

In "obj" I have encrypted data. Whenever am passing variable through ajax call and encrypted data appearing on console. I want to be keep my data more secure please help me in this.

var encrydata = encyData(obj);
$.ajax({
    url: "web/decyData", 
    "type": "POST",
    async:true,
    data:{   
        json : encrydata ,
    },    

thanks in advance

5
  • 1
    Possible duplicate of Java to JS and JS to Java encryption using cryptojs Commented Dec 22, 2017 at 7:20
  • 1
    The simplest way to achieve your goal is to use https instead of http, that way you don't need to worry about encryption, the browser and webserver will deal with it. Commented Dec 22, 2017 at 7:36
  • what do you mean by choice to encrypt variables? there is always a way how to encrypt/decrypt data in Java. The question is - can you see how the data are encrypted and what is the posted payload? Commented Dec 22, 2017 at 9:31
  • 1
    Who exactly do you want to "protect" this data from? The end user (solved through DRM in the browser) or somebody who listens on the connection (solved through https)? Commented Dec 22, 2017 at 12:49
  • Is there any choice? Sure, HTTPS, SSH, XML-enc, CMS, PGP, Fernet and dozens of other schemes and that's not even counting how to format the data before encryption (JSON, XML, Binary). However, as @ArtjomB. already mentioned: it depends on your use case and threat model which one would be applicable (if any). This is the XY-problem (Google it!), closing: unclear what you are asking. Protocol questions on Security.SE please. Commented Dec 22, 2017 at 14:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.