简体   繁体   中英

Java - Are there any ways to obfuscate/hide strings to prevent against decompilation?

I just have a handful of Strings that I would like to obfuscate/hide against decompilation. I'm aware that I'll never be able to achieve true prevention but I am hoping there are any/some ways that will at least prevent the actual Strings from showing up exactly as they are.

Any help would be much appreciated.

You can put them in a resource file and encrypt it using AES (for example). Then on the application initialization extract the data.

There are a number of free and commercial "java code obfuscators" that change names of non-public API and do simple transformations of string literals. This obfuscation won't stop a determined attacker, but it will discourage casual observation.

My favorite method is to declare them encoded in base64. Then its just a simple library call to decode the string out of them an use whenever needed. This obfuscates the string and its length both

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM