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

NRV
  • 17
  • 8
  • 1
    Possible duplicate of [Java to JS and JS to Java encryption using cryptojs](https://stackoverflow.com/questions/30382014/java-to-js-and-js-to-java-encryption-using-cryptojs) – vinS Dec 22 '17 at 07: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. – MartinByers Dec 22 '17 at 07:36
  • what do you mean by `choice to encrypt variables`? there is always a way [how to encrypt/decrypt data](https://gusto77.wordpress.com/2017/10/30/encryption-reference-project/) in Java. The question is - can you see how the data are encrypted and what is the posted payload? – gusto2 Dec 22 '17 at 09: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)? – Artjom B. Dec 22 '17 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. – Maarten Bodewes Dec 22 '17 at 14:06

0 Answers0