### Question:
Crypto { public static byte[] aesEncrypt(byte[] plaintext, byte[] key) { try { byte[] iv = new byte[16]; secureRandom.get().nextBytes(iv); PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher( new AESEngine())); CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv); aes.init(true, ivAndKey); byte[] output = new byte[aes.getOutputSize(plaintext.length)]; int ciphertextLength = aes.processBytes(plaintext, 0, plaintext.length, output, 0); ciphertextLength += aes.doFinal(output, ciphertextLength); byte[] result = new byte[iv.length + ciphertextLength]; System.arraycopy(iv, 0, result, 0, iv.length); System.arraycopy(output, 0, result, iv.length, ciphertextLength); return result; } catch (InvalidCipherTextException e) { throw new RuntimeException(e.getMessage(), e); } } private  Crypto(); static SecureRandom getSecureRandom(); static MessageDigest getMessageDigest(String algorithm); static MessageDigest sha256(); static MessageDigest sha512(); static MessageDigest ripemd160(); static MessageDigest sha3(); static byte[] getKeySeed(String secretPhrase, byte[]... nonces); static byte[] getKeySeed(byte[] secretBytes, byte[]... nonces); static byte[] getPublicKey(byte[] keySeed); static byte[] getPublicKey(String secretPhrase); static byte[] getPrivateKey(byte[] keySeed); static byte[] getPrivateKey(String secretPhrase); static void curve(byte[] Z, byte[] k, byte[] P); static byte[] sign(byte[] message, String secretPhrase); static byte[] sign(byte[] message, byte[] keySeed); static boolean verify(byte[] signature, byte[] message, byte[] publicKey); static byte[] getSharedKey(byte[] myPrivateKey, byte[] theirPublicKey); static byte[] getSharedKey(byte[] myPrivateKey, byte[] theirPublicKey, byte[] nonce); static byte[] aesEncrypt(byte[] plaintext, byte[] key); static byte[] aesGCMEncrypt(byte[] plaintext, byte[] key); static byte[] aesDecrypt(byte[] ivCiphertext, byte[] key); static byte[] aesGCMDecrypt(byte[] ivCiphertext, byte[] key); static String rsEncode(long id); static long rsDecode(String rsString); static boolean isCanonicalPublicKey(byte[] publicKey); static boolean isCanonicalSignature(byte[] signature); static FBElGamalKeyPair getElGamalKeyPair(); static String elGamalDecrypt(String cryptogramm, FBElGamalKeyPair keyPair); static String elGamalEncrypt(String plainText, FBElGamalKeyPair keyPair);  }### Answer:
@Test public void testAesEncrypt() throws IOException { byte[] plaintext =plain_data; byte[] myPrivateKey = Crypto.getPrivateKey(secretPhraseA); byte[] theirPublicKey = Crypto.getPublicKey(secretPhraseB); byte[] key = Crypto.getSharedKey(myPrivateKey, theirPublicKey); byte[] expResult = plaintext; byte[] result_enc = Crypto.aesEncrypt(plaintext, key); byte[] result = Crypto.aesDecrypt(result_enc, key); assertArrayEquals(expResult, result); writeToFile(ByteBuffer.wrap(result_enc), TST_OUT_DIR+OUT_FILE_AES); }