private static String encrypt(final int key, final String text) {
        String encryptedText = "";
        logger.log(Level.INFO, "Plain text: {0}", text);
        for (int level = 0; level < key; level++) {
            for (int n = 0; n < text.length() / (2 * key - 2) + 1; n++) {
                if (level != 0 && level != key - 1 && 2 * n * (key - 1) - level > -1) {
                    encryptedText += text.charAt(2 * n * (key - 1) - level);
                }
                if (2 * n * (key - 1) + level < text.length()) {
                    encryptedText += text.charAt(2 * n * (key - 1) + level);
                }
            }
        }
        logger.log(Level.INFO, "Encrypted text: {0}", encryptedText);
        return encryptedText;
    }