All pastes #987585 Raw Edit

Jemand

public text v1 · immutable
·published 2008-04-16 17:09 UTC
rendered paste body
/**
 * @author 
 * @version 
 */
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)
    {
        //int ergebnis = 0;
        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;
                      
                    }    
                }
                
                int[]haeufig = new int[26];
               
                System.out.println(alpha[j]+"="+ anzahl);
            }
         
     } 
           

}