@Test public void runTest() { assertEquals("RBQRGLDRFGQ", Keyword.keyword("TESTINGTHIS", "TEST", Mode.ENCRYPT)); assertEquals("TESTINGTHIS", Keyword.keyword("RBQRGLDRFGQ", "TEST", Mode.DECRYPT)); }
public static String keyword(String input, String key, Mode mode) { input = input.toLowerCase(); char[] table = createTable(removeDuplicates(key.toLowerCase())); StringBuilder output = new StringBuilder(); if (mode == Mode.ENCRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, true)); } } if (mode == Mode.DECRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, false)); } } return output.toString().toUpperCase(); }
Keyword { public static String keyword(String input, String key, Mode mode) { input = input.toLowerCase(); char[] table = createTable(removeDuplicates(key.toLowerCase())); StringBuilder output = new StringBuilder(); if (mode == Mode.ENCRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, true)); } } if (mode == Mode.DECRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, false)); } } return output.toString().toUpperCase(); } }
Keyword { public static String keyword(String input, String key, Mode mode) { input = input.toLowerCase(); char[] table = createTable(removeDuplicates(key.toLowerCase())); StringBuilder output = new StringBuilder(); if (mode == Mode.ENCRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, true)); } } if (mode == Mode.DECRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, false)); } } return output.toString().toUpperCase(); }  }
Keyword { public static String keyword(String input, String key, Mode mode) { input = input.toLowerCase(); char[] table = createTable(removeDuplicates(key.toLowerCase())); StringBuilder output = new StringBuilder(); if (mode == Mode.ENCRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, true)); } } if (mode == Mode.DECRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, false)); } } return output.toString().toUpperCase(); }  static void main(String[] args); static String keyword(String input, String key, Mode mode); }
Keyword { public static String keyword(String input, String key, Mode mode) { input = input.toLowerCase(); char[] table = createTable(removeDuplicates(key.toLowerCase())); StringBuilder output = new StringBuilder(); if (mode == Mode.ENCRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, true)); } } if (mode == Mode.DECRYPT) { for (int i = 0; i < input.length(); i++) { output.append(getChar(input.charAt(i), table, true, false)); } } return output.toString().toUpperCase(); }  static void main(String[] args); static String keyword(String input, String key, Mode mode);  }