Sample code for 30+ languages & platforms
Java

Obfuscate String

Demonstrates how to obfuscate and unobfuscate a string.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.StringBuilder;

public class ChilkatExample {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();

        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.
        StringBuilder sb2 = new StringBuilder();
        String s2 = "2GsgGhbSQVyG8Vb9";
        sb2.append(s2);
        sb2.unobfuscate();

        System.out.println(sb2.getAsString());

        // Output is "Hello World!";
    }
}