{% else-1 %}

                        
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.*;

public class Main extends MIDlet {

public void startApp() {
String s = "Текст", key = "Ключ";
Form f = new Form("XOR");
s = CryptXOR(s, key);
f.append("Криптуем..n" + s);
f.append("nДекриптуем..n" + CryptXOR(s, key));
Display.getDisplay(this).setCurrent(f);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

private String CryptXOR(String s, String k) {
char[] buf = s.toCharArray(), key = k.toCharArray();
for (int i = 0, a = 0; i < buf.length; i++, a++) {
buf[i] = (char) (buf[i] ^ key[a]);
if (a == key.length - 1) {
a = 0;
}
}
s = new String(buf);
return s;
}
}
0 26 0
Без комментариев...