### Question:
Message { public static byte[] decrypt(byte []encrypted, SecretKeySpec aes) throws InvalidKeyException, IllegalArgumentException { if (encrypted.length < NONCE_SIZE + OVERHEAD) { throw new IllegalArgumentException("Encrypted message size is too short"); } final Cipher cipher; try { cipher = Cipher.getInstance(CIPHER); } catch (NoSuchAlgorithmException | NoSuchPaddingException error) { throw new IllegalArgumentException(error.getMessage()); } final byte[] nonce = Arrays.copyOfRange(encrypted, 0, NONCE_SIZE); final byte[] encryptedAndTag = Arrays.copyOfRange(encrypted, NONCE_SIZE, encrypted.length); final GCMParameterSpec gcm = new GCMParameterSpec(TAG_BITS, nonce); try { cipher.init(Cipher.DECRYPT_MODE, aes, gcm); } catch (InvalidAlgorithmParameterException error) { throw new IllegalArgumentException(error.getMessage()); } try { return cipher.doFinal(encryptedAndTag); } catch(BadPaddingException | IllegalBlockSizeException error) { throw new IllegalArgumentException(error.getMessage()); } }  static byte[] encrypt(byte[] decrypted, SecretKeySpec aes); static byte[] encrypt(String decrypted, SecretKeySpec aes); static byte[] encrypt(byte[] decrypted, byte[] aesBytes); static byte[] encrypt(String decrypted, byte[] aesBytes); static byte[] decrypt(byte []encrypted, SecretKeySpec aes); static byte[] decrypt(String encrypted, SecretKeySpec aes); static byte[] decrypt(byte []encrypted, byte[] aesBytes); static byte[] decrypt(String encrypted, byte[] aesBytes); static String ALGORITHM; static String CIPHER; static int NONCE_SIZE; static int TAG_BITS; static int OVERHEAD; }### Answer:
@Test public void decryptingAMessage() throws Exception { System.out.println("MessageTest.decrypting a message: " + vector); final byte[] want = vector.getBytes("plaintext"); final byte[] test = Message.decrypt(Helper.combine(vector.getBytes("nonce"), vector.getBytes("ciphertext")), vector.getBytes("key")); System.out.println("encrypted:"); Hex.dump(Helper.combine(vector.getBytes("nonce"), vector.getBytes("ciphertext"))); System.out.println("decrypted:"); Hex.dump(test); assertThat("decrypt retusn byte[]", test instanceof byte[], is(true)); assertThat("decryption succeeds", test, equalTo(want)); }