(Java) Obfuscate String
Demonstrates how to obfuscate and unobfuscate a string.
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
CkStringBuilder sb = new CkStringBuilder();
boolean success;
String s = "Hello World!";
sb.Append(s);
System.out.println(sb.getAsString());
// Output is "Hello World!";
// Obfuscate the string.
// This is NOT encryption. It's just a simple obfuscation.
sb.Obfuscate();
System.out.println(sb.getAsString());
// Output is 2GsgGhbSQVyG8Vb9
// -------------------------
// Unobfuscate.
CkStringBuilder sb2 = new CkStringBuilder();
String s2 = "2GsgGhbSQVyG8Vb9";
sb2.Append(s2);
sb2.Unobfuscate();
System.out.println(sb2.getAsString());
// Output is "Hello World!";
}
}
|