All pastes #768685 Raw Edit

Etwas

public java v1 · immutable
·published 2007-11-10 20:25 UTC
rendered paste body
public class Caesar {	public static void main(String[] args) {		int schluessel = Integer.parseInt(args[0]);		System.out.println("Geben sie den zu verschlüsselnden Text ein: \n");		String klartext = GdAInput.readLine();		System.out.println("Verwendeter Schlüssel: " + schluessel);		System.out.println("Zu verschlüsselnder Text: \n" + klartext);		String verschlüsselt = encrypt(klartext, schluessel);		System.out.println("verschlüsselter Text: \n" + verschlüsselt);		String entschlüsselt = encrypt(verschlüsselt, -schluessel);		System.out.println("entschlüsselter Text: \n" + entschlüsselt);	}	public static boolean satzzeichen(int buchstabe) {		if (buchstabe < 65 | buchstabe > 90 & buchstabe < 97 | buchstabe > 122) {			return (true);		}		else			return (false);	}	public static String encrypt(String str, int offset) {		final int stringlaenge = str.length();		int zahlchar[] = new int[stringlaenge]; // Zahlenarray mit Länge des		// Strings		int n = 0;		String crypted = "";		while (n < stringlaenge) {			zahlchar[n] = (int) str.charAt(n);			int zeichen = 97;						if (satzzeichen(zahlchar[n])==true) {				zeichen = zahlchar[n];			}			if (zahlchar[n] < 91 & zahlchar[n] != 32) {				zahlchar[n] = zahlchar[n] + 32;//+ offset; //Großbuchstaben			}			if (zahlchar[n] > 90) {				zahlchar[n] = zahlchar[n] + offset; //Kleinbuchstaben			}			if (zahlchar[n] > 122) {				zahlchar[n] = zahlchar[n] - 26;			}			if (zahlchar[n] < 91 & zahlchar[n] != 32) {				zahlchar[n] = zahlchar[n] + 26;			}			if (satzzeichen(zeichen)==true) {				zahlchar[n] = zeichen;			}							n++;		}		n = 0;		while (n < stringlaenge) {			crypted = crypted + (char) zahlchar[n];			n++;		}		return (crypted);	}}