I'm looking for a secure way to encrypt my API data in order to prevent users from viewing it in the network tab or as plain text within objects like window.__nuxt__
.
Currently, I am following these steps:
- Encrypting data on the back-end using a secret string (like a password)
- Sending the encrypted data to the front-end
- Decrypting it on the client-side using the same password used in the back-end
However, I have encountered an issue: The decryption function can potentially be accessed by inspecting the bundled JavaScript files in the browser.
Even though the function is obfuscated, it could still be reverse-engineered. Additionally, since the password is embedded within the function (as there are no process.env variables available on the client-side), there is a risk of unauthorized access to the data.
What would be the most effective method to mitigate this risk?
I am aware that the data will eventually be visible in the browser, but I aim to prevent it from appearing as plain text.
For reference, I am utilizing Express in the back-end and NuxtJS in the front-end.