code: public byte[] encrypt(byte[] decryptedInput) throws CryptoException, IncompatibleDeviceException {
          try {
              SecretKey key = new SecretKeySpec(getAESKey(), ALGORITHM_AES);
              Cipher cipher = Cipher.getInstance(AES_TRANSFORMATION);
              cipher.init(Cipher.ENCRYPT_MODE, key);
              byte[] encrypted = cipher.doFinal(decryptedInput);
              byte[] encodedIV = Base64.encode(cipher.getIV(), Base64.DEFAULT);
              //Save IV for Decrypt stage
              storage.store(KEY_IV_ALIAS, new String(encodedIV));
              return encrypted;
          } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
              /*
               * This exceptions are safe to be ignored:
               *
               * - NoSuchPaddingException:
               *      Thrown if NOPADDING is not available. Was introduced in API 1.
               * - NoSuchAlgorithmException:
               *      Thrown if the transformation is null, empty or invalid, or if no security provider
               *      implements it. Was introduced in API 1.
               * - InvalidKeyException:
               *      Thrown if the given key is inappropriate for initializing this cipher.
               * - InvalidAlgorithmParameterException:
               *      If the IV parameter is null.
               * - BadPaddingException:
               *      Thrown only on decrypt mode.
               *
               * Read more in https://developer.android.com/reference/javax/crypto/Cipher
               */
              Log.e(TAG, "Error while encrypting the input.", e);
              throw new IncompatibleDeviceException(e);
          } catch (IllegalBlockSizeException | BadPaddingException e) {
              /*
               * - IllegalBlockSizeException:
               *      Thrown if no padding has been requested and the length is not multiple of block size.
               * - BadPaddingException:
               *      Thrown only on decrypt mode.
               */
              throw new CryptoException("The AES decrypted input is invalid.", e);
          }
      }
docs: Encrypts the given input bytes using a symmetric key (AES).
  The AES key is stored protected by an asymmetric key pair (RSA).
  
  @param decryptedInput the input bytes to encrypt. There's no limit in size.
  @return the encrypted output bytes
  @throws CryptoException             if the RSA Key pair was deemed invalid and got deleted. Operation can be retried.
  @throws IncompatibleDeviceException in the event the device can't understand the cryptographic settings required