0

Is possible to hide content code of a javascript function, I am using JSP

I want to hide a function like this

function changePassword(){
var oldPassword = document.getElementById("oldPwd");
var newPassword = document.getElementById("newPwd");
var repeatedPwd = document.getElementById("newPwdRepeated");
//Ajax to BackEnd with encrypted data
}

I want to hide the encryption process when the end user use Dev Tools in browser

Sorry for my english

2
  • AFAK, the JS code get interpreted on the user's browser, so it's a "public" script. Commented Dec 24, 2020 at 16:25
  • your best bet is obfuscation Commented Dec 24, 2020 at 16:30

1 Answer 1

1

It's not really possible.

While there exists a proposal to hide the programmatic examination of functions, there's nothing stopping a user from examining the source code manually.

If program logic runs on the client's machine, the client will have to have been sent the source code for that logic somehow - anyone sufficiently determined will be able to find it. The only way to keep such an implementation hidden from the client is to not send it to the client at all.

While you could try to make the process safer by creating your own implementation of SSL encryption, it would make much more sense and would be much safer to simply require all connections over HTTPS - leave it to the browser and server to automatically encrypt and decrypt messages safely. If the connection is secure, you won't have to worry about the password being intercepted by someone in the middle - unless the client's browser is compromised, or unless the client's network / OS is compromised (and in such cases, safe communication is pretty much impossible anyway).

Sign up to request clarification or add additional context in comments.

Comments

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.