How to easily encode and decode a string variable

I just need to encode a string variable (my api key), so it is not easily readable by human eyes, I need it to be easily decoded back to the same initial string. What is the standard practical and quick (less computation on the user side) way to do this?

Thank you very much in advance!

+4
source share
5 answers

If it should not be super safe, Base64 encoding is always convenient:

http://www.webtoolkit.info/javascript-base64.html

+3
source

All you can do to obfuscate information on the client is to include code to de-obfuscate next to it.

So ... apart from adding one extra step for your program (and a hypothetical attacker) you get nothing. Well, not so much.

If your API key is secret, save it on the server and let the server do the work through HTTP requests.

0
source

You can try Javascript Obfuscator to encode all of your script or parts. Not an absolute solution, but the beginning of protecting your code.

0
source

you can use a third-party base64 encoder library: http://ostermiller.org/utils/Base64.html

0
source

Is this classified information or not?

If this is a secret, you need a real encryption library as well as deep thinking to make sure your secret is kept secret. I would seriously think about never sending any secret to the browser.

If this is not a secret, and you just need to send it to the URL without getting borked, then escape () / unescape () is what you are looking for.

0
source

Source: https://habr.com/ru/post/1307360/


All Articles