AESEncryptAlgorithm implements EncryptAlgorithm { @SneakyThrows(GeneralSecurityException.class) @Override public String encrypt(final Object plaintext) { if (null == plaintext) { return null; } byte[] result = getCipher(Cipher.ENCRYPT_MODE).doFinal(StringUtils.getBytesUtf8(String.valueOf(plaintext))); return Base64.encodeBase64String(result); }  @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 assertEncrypt() { assertThat(encryptAlgorithm.encrypt("test"), is("dSpPiyENQGDUXMKFMJPGWA==")); }
@Test public void assertEncryptWithNullPlaintext() { assertNull(encryptAlgorithm.encrypt(null)); }