All pastes #988167 Raw Edit

Anonym

public text v1 · immutable
#988167 ·published 2008-04-17 10:58 UTC
rendered paste body
import java.lang.Object;
import java.util.Arrays;
/**
 * @author 
 * @version http://pastebin.ca/987700
 */
public abstract class kodiereBuchst
{    
    public static char kodiereBuchst(char x, int i){
        if ( ((int) x >= 97 && (int) x <= 122)|| ((int) x >= 'A' && (int) x <= 'Z') ){
            if (((int) x + i <= 122) || ((int) x + i <= 'Z')){
                return x= (char) ((int)x + i);
            }else{ 
                return x = (char) ((int)x-(26-i));  
            }
        }else{ 
            if( (int)x == (int) 32){
            return (int) 32;
        }
            return 0;
    }
}

    
    public static String kodiereString(String str, int schluessel)
    {
        char[]strArray = str.toCharArray();
        for(int i= 0; i < str.length(); i++){
        strArray[i] = kodiereBuchst(strArray[i], schluessel);
        }
        return new String (strArray);
    
    }
    
    public static void attackVer(String str)
    {
        String alphabet = new String("abcdefghijklmnopqrstuvwxyz");
        char[]alpha = alphabet.toCharArray();
        char[]eingabe = str.toCharArray();
            for (int j=0; j <26; j++){
                int anzahl=0;
                for (int i= 0; i < str.length(); i++)
                {
                    if (alpha[j] == str.charAt(i)){
                        anzahl = anzahl +1;
                      
                    }    
                }
                anzahlDerBuchstaben[j] = anzahl;
               
            }
         double[] haeufigkeit =new double[26];
         for(int k =0; k < 26; k++){
            haeufigkeit[k]= ((double)anzahlDerBuchstaben[k] / (str.length()))*100;
            }
//          double[] geordneteHaeufigkeiten = Arrays.copyOf(haeufigkeit, haeufigkeit.length);
//          Arrays.sort(geordneteHaeufigkeiten);

         System.out.println(haeufigkeit[4]);
     }
     static int[] anzahlDerBuchstaben = new int[26];             

}