AESEncryptAlgorithm implements EncryptAlgorithm { @SneakyThrows(GeneralSecurityException.class) @Override public Object decrypt(final String ciphertext) { if (null == ciphertext) { return null; } byte[] result = getCipher(Cipher.DECRYPT_MODE).doFinal(Base64.decodeBase64(ciphertext)); return new String(result, StandardCharsets.UTF_8); }  @Override void init(); @SneakyThrows(GeneralSecurityException.class) @Override String encrypt(final Object plaintext); @SneakyThrows(GeneralSecurityException.class) @Override Object decrypt(final String ciphertext); @Override String getType();  }
@Test public void assertDecrypt() { assertThat(encryptAlgorithm.decrypt("dSpPiyENQGDUXMKFMJPGWA==").toString(), is("test")); }
@Test public void assertDecryptWithNullCiphertext() { assertNull(encryptAlgorithm.decrypt(null)); }