@Test public void should_decrypt2() throws CipherException { assertThat(CipherUtils.decrypt(CIPHER_TEXT2, KEY1), is(PLAIN_TEXT2)); }
public static String decrypt(String cipherText, String key) throws CipherException { try { Cipher cipher = Cipher.getInstance(CIPHER_INSTANCE); cipher.init(Cipher.DECRYPT_MODE, stringToKey(key)); byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(cipherText.getBytes(UTF_8))); return new String(decrypted, UTF_8); } catch (Exception e) { throw new CipherException("Cannot decrypt", e); } }
CipherUtils { public static String decrypt(String cipherText, String key) throws CipherException { try { Cipher cipher = Cipher.getInstance(CIPHER_INSTANCE); cipher.init(Cipher.DECRYPT_MODE, stringToKey(key)); byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(cipherText.getBytes(UTF_8))); return new String(decrypted, UTF_8); } catch (Exception e) { throw new CipherException("Cannot decrypt", e); } } }
CipherUtils { public static String decrypt(String cipherText, String key) throws CipherException { try { Cipher cipher = Cipher.getInstance(CIPHER_INSTANCE); cipher.init(Cipher.DECRYPT_MODE, stringToKey(key)); byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(cipherText.getBytes(UTF_8))); return new String(decrypted, UTF_8); } catch (Exception e) { throw new CipherException("Cannot decrypt", e); } }  }
CipherUtils { public static String decrypt(String cipherText, String key) throws CipherException { try { Cipher cipher = Cipher.getInstance(CIPHER_INSTANCE); cipher.init(Cipher.DECRYPT_MODE, stringToKey(key)); byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(cipherText.getBytes(UTF_8))); return new String(decrypted, UTF_8); } catch (Exception e) { throw new CipherException("Cannot decrypt", e); } }  static String encrypt(String plainText, String key); static String decrypt(String cipherText, String key); }
CipherUtils { public static String decrypt(String cipherText, String key) throws CipherException { try { Cipher cipher = Cipher.getInstance(CIPHER_INSTANCE); cipher.init(Cipher.DECRYPT_MODE, stringToKey(key)); byte[] decrypted = cipher.doFinal(Base64.getDecoder().decode(cipherText.getBytes(UTF_8))); return new String(decrypted, UTF_8); } catch (Exception e) { throw new CipherException("Cannot decrypt", e); } }  static String encrypt(String plainText, String key); static String decrypt(String cipherText, String key);  }