src/main/java/cezar/encrypt/CezarEncryption.java
public String encrypt(String text, int shift) {
        this.shift = shift;
        char[] chars = text.toLowerCase().toCharArray();
        StringBuffer output = new StringBuffer();

        for (int i=0; i<chars.length; i++) {
            if (Character.isAlphabetic(chars[i])) {
                int index = alphabetIndex.get(chars[i]);
                // index from 0 to 25
                index = calculateIndex(index);
                output.append(alphabet[index]);
                continue;
            }
            output.append(chars[i]);
        }

        return output.toString();
    }
/**
     * Iterate through plain text and shift every letter by X places.
     * @param text
     * @return String encrypted text
     */
Iterate through plain text and shift every letter by X places.
@param text
@return String encrypted text
Iterate through plain text and shift every letter by X places . @param text @return String encrypted text
public String encrypt(String text, int shift) {
        this.shift = shift;
        char[] chars = text.toLowerCase().toCharArray();
        StringBuffer output = new StringBuffer();
        for (int i=0; i<chars.length; i++) {
            if (Character.isAlphabetic(chars[i])) {
                int index = alphabetIndex.get(chars[i]);
                index = calculateIndex(index);
                output.append(alphabet[index]);
                continue;
            }
            output.append(chars[i]);
        }
        return output.toString();
    }
public String encrypt ( String text , int shift ) { this . shift = shift ; char [ ] chars = text . toLowerCase ( ) . toCharArray ( ) ; StringBuffer output = new StringBuffer ( ) ; for ( int i = 0 ; i < chars . length ; i ++ ) { if ( Character . isAlphabetic ( chars [ i ] ) ) { int index = alphabetIndex . get ( chars [ i ] ) ; index = calculateIndex ( index ) ; output . append ( alphabet [ index ] ) ; continue ; } output . append ( chars [ i ] ) ; } return output . toString ( ) ; }
Iterate through plain text and shift every letter by X places.
Iterate through plain text and shift every letter by X places .
// index from 0 to 25