@Test public void runTest() { assertEquals("IJNPR", Gronsfeld.gronsfeld("HELLO", "15243", Mode.ENCRYPT)); assertEquals("HELLO", Gronsfeld.gronsfeld("IJNPR", "15243", Mode.DECRYPT)); }
public static String gronsfeld(String input, String keyword, Mode mode) { String output = ""; if (mode == Mode.ENCRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } if (mode == Mode.DECRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } return output; }
Gronsfeld { public static String gronsfeld(String input, String keyword, Mode mode) { String output = ""; if (mode == Mode.ENCRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } if (mode == Mode.DECRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } return output; } }
Gronsfeld { public static String gronsfeld(String input, String keyword, Mode mode) { String output = ""; if (mode == Mode.ENCRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } if (mode == Mode.DECRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } return output; }  }
Gronsfeld { public static String gronsfeld(String input, String keyword, Mode mode) { String output = ""; if (mode == Mode.ENCRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } if (mode == Mode.DECRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } return output; }  static void main(String[] args); static String gronsfeld(String input, String keyword, Mode mode); }
Gronsfeld { public static String gronsfeld(String input, String keyword, Mode mode) { String output = ""; if (mode == Mode.ENCRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } if (mode == Mode.DECRYPT) { input = formatInputString(input); int[] numericInput = turnInputNumeric(input); keyword = formatKeywordString(keyword); String lengthenedKeyword = generateGronsfeldKeyword(keyword, input); int[] numericKeyword = turnKeywordNumeric(lengthenedKeyword); addedNumeric = addNumericStrings(mode, numericInput, numericKeyword); output = turnAlpha(addedNumeric); } return output; }  static void main(String[] args); static String gronsfeld(String input, String keyword, Mode mode);  }