code: public static String encrypt(String data, byte[] key)
      {
          try
          {
              Key k = toSecretKey(key);
              Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
              cipher.init(Cipher.ENCRYPT_MODE, k);
              byte[] toByteArray = data.getBytes();
              byte[] encrypted = cipher.doFinal(toByteArray);
              return Hex.encodeHexString(encrypted);
          }
          catch (GeneralSecurityException e)
          {
              throw new RuntimeException("Failed to encrypt.", e);
          }
      }
docs: Encrypt.
  
  @param data the data
  @param key the key
  @return the string