@Test public void runTest() { assertEquals("svooldliow", Atbash.atbash("helloworld", Mode.ENCRYPT)); assertEquals("helloworld", Atbash.atbash("svooldliow", Mode.DECRYPT)); }
public static String atbash(String inputText, final Mode mode) { try { inputText = inputText.toLowerCase(); String output = null; if (mode == Mode.ENCRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder cyphered = new StringBuilder(); for (char c : encoded.toCharArray()) { cyphered.append(applyCipher(c)); } output = cyphered.toString(); } if (mode == Mode.DECRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder deciphered = new StringBuilder(); for (char c : encoded.toCharArray()) { deciphered.append(applyCipher(c)); } output = deciphered.toString(); } return output; } catch (Exception e) { return e.toString(); } }
Atbash { public static String atbash(String inputText, final Mode mode) { try { inputText = inputText.toLowerCase(); String output = null; if (mode == Mode.ENCRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder cyphered = new StringBuilder(); for (char c : encoded.toCharArray()) { cyphered.append(applyCipher(c)); } output = cyphered.toString(); } if (mode == Mode.DECRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder deciphered = new StringBuilder(); for (char c : encoded.toCharArray()) { deciphered.append(applyCipher(c)); } output = deciphered.toString(); } return output; } catch (Exception e) { return e.toString(); } } }
Atbash { public static String atbash(String inputText, final Mode mode) { try { inputText = inputText.toLowerCase(); String output = null; if (mode == Mode.ENCRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder cyphered = new StringBuilder(); for (char c : encoded.toCharArray()) { cyphered.append(applyCipher(c)); } output = cyphered.toString(); } if (mode == Mode.DECRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder deciphered = new StringBuilder(); for (char c : encoded.toCharArray()) { deciphered.append(applyCipher(c)); } output = deciphered.toString(); } return output; } catch (Exception e) { return e.toString(); } }  }
Atbash { public static String atbash(String inputText, final Mode mode) { try { inputText = inputText.toLowerCase(); String output = null; if (mode == Mode.ENCRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder cyphered = new StringBuilder(); for (char c : encoded.toCharArray()) { cyphered.append(applyCipher(c)); } output = cyphered.toString(); } if (mode == Mode.DECRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder deciphered = new StringBuilder(); for (char c : encoded.toCharArray()) { deciphered.append(applyCipher(c)); } output = deciphered.toString(); } return output; } catch (Exception e) { return e.toString(); } }  static void main(String[] args); static String atbash(String inputText, final Mode mode); }
Atbash { public static String atbash(String inputText, final Mode mode) { try { inputText = inputText.toLowerCase(); String output = null; if (mode == Mode.ENCRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder cyphered = new StringBuilder(); for (char c : encoded.toCharArray()) { cyphered.append(applyCipher(c)); } output = cyphered.toString(); } if (mode == Mode.DECRYPT) { String encoded = stripInvalidCharacters(inputText).toLowerCase(); StringBuilder deciphered = new StringBuilder(); for (char c : encoded.toCharArray()) { deciphered.append(applyCipher(c)); } output = deciphered.toString(); } return output; } catch (Exception e) { return e.toString(); } }  static void main(String[] args); static String atbash(String inputText, final Mode mode);  }