public final class ObfuscatedString extends Object
io.keikaiex.license.LicenseParam
,
io.keikaiex.license.KeyStoreParam
and io.keikaiex.license.CipherParam
interfaces in order to
make it considerably hard (although still not impossible) for a reverse
engineer to find these string literals while providing comparably fast
operation and minimum memory footprint.
To use this class you need to provide the string literal to obfuscate as a
parameter to the static obfuscate(java.lang.String)
method.
Its return value is a string which contains the Java code which you should
substitute for the string literal in the client application's source code.
Please note that obfuscation is not equal to encryption: In contrast to the obfuscation provided by this class, encryption is comparably slow and expensive in terms of resources - no matter what algorithm is actually used. More importantly, encrypting string literals in Java code does not really increase the privacy of these strings compared to obfuscation as long as the encryption key is still placed in the Java code itself and tracing the calls to the JVM is possible. Hence, obfuscation is selected in favour of encryption.
In order to provide a reasonable level of security for your application, you should always obfuscate the application code too, including this class. Otherwise, a reverse engineer could simply use the UNIX "strings" utility to search for all usages of this class, which would render its use completely pointless! In case you're looking for a Java code obfuscation tool for this task, please consider ProGuard, available and usable for free at http://proguard.sourceforge.net.
This class is designed to be thread safe.
Constructor and Description |
---|
ObfuscatedString(long[] obfuscated)
Constructs an obfuscated string.
|
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args)
Obfuscates each given argument.
|
static String |
obfuscate(String s)
Returns a string containing obfuscated string generating Java code which
you can copy-paste into your source code in order to represent the given
string.
|
String |
toString()
Returns the original string.
|
public ObfuscatedString(long[] obfuscated)
obfuscated
- The obfuscated string.NullPointerException
- If obfuscated
is
null
.ArrayIndexOutOfBoundsException
- If the provided array does not
contain at least one element.obfuscate(String)
public static void main(String[] args)
args
- The command line arguments.public static String obfuscate(String s)
As an example, calling this method with "Hello world!"
as
its parameter may produce the result
"new ObfuscatedString(new long[] {
0x3676CB307FBD35FEL, 0xECFB991E2033C169L, 0xD8C3D3E365645589L
}).toString()"
.
If this code is compiled and executed later, it will produce the string
"Hello world!"
again.
s
- The string to obfuscate. This may not contain null characters.IllegalArgumentException
- If s
contains a null
character.Copyright © 2020. All rights reserved.