1

I want to hide a variable value in js so that no one can see what value the variable has from outside world. Suppose I have the following code,

var ID = 'some_id';

I dont want someone to see the string 'some_id' by viewing the source from browser.

1 Answers1

2

Well if you are using a client-side scripting language like javascript then it is not possible. There are some ways to encode your js code but there are more ways to decrypt those. So there is no 100% solution available for a client-side code to hide from the end user.

I will recommend you to use a server side language to hide sensitive data. But if you really want to go with client-side then you can use obfuscation your code which I already told you is not a 100% solution.

I hope I have described it well.

azizsagi
  • 268
  • 3
  • 12