class CryptoUtils {

  public static byte[] encryptToAesGcm(final byte[] message, final byte[] password,
      final byte[] nonce) throws IllegalStateException, InvalidCipherTextException {
    final GCMBlockCipher cipher = new GCMBlockCipher(new AESEngine());
    CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(password), nonce);
    cipher.init(true, ivAndKey);
    final byte[] outBuf = new byte[cipher.getOutputSize(message.length)];
    int outOff = cipher.processBytes(message, 0, message.length, outBuf, 0);
    cipher.doFinal(outBuf, outOff);
    return outBuf;
  }

}