Verschlüsselung 1 2 import java.awt.*; import java.applet.*; 3 4 5 public class codierung extends Applet { TextArea textein, textaus; StringBuffer eingabe, ausgabe; Einführung 6 7 8 9 10 11 12 13 14 public void init( ) { setLayout(new GridLayout(3, 2)); add(new Label("Eingabe")); add(textein=new TextArea(3, 20)); add(new Label( )); add(new Button("Codieren")); add(new Label("Ausgabe")); add(textaus=new TextArea(3, 20)); } 15 16 17 18 public boolean action(Event e, Object o) { verschluesseln( ); return true; } 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 void verschluesseln( ) { int i = 0; int x; char ch; StringBuffer text = new StringBuffer( ); String s; textaus.setText(""); s = textein.getText( ); int laenge = s.length( ); while (i < laenge) { ch = s.charAt(i); x = (int) ch ; // ASCII-Code x = x+3; //American Standard Code for Information Interchange text.append( (char) x); i++; } textaus.append(text.toString( )); } 35 }