public static Optional<String> encrypt(String key, String text) {
        try {
            Cipher cipher = Cipher.getInstance(AES_PADDING);
            byte[] keyBytes = Base64.getDecoder().decode(key.getBytes(DEFAULT_ENCODE));
            SecretKey secretKey = new SecretKeySpec(keyBytes, ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, secretKey);
            byte[] encryptBytes = cipher.doFinal(text.getBytes(DEFAULT_ENCODE));
            byte[] bytes = new byte[IV_LENGTH + text.getBytes(DEFAULT_ENCODE).length + LENGTH];
            System.arraycopy(cipher.getIV(), 0, bytes, 0, IV_LENGTH);
            System.arraycopy(encryptBytes, 0, bytes, IV_LENGTH, encryptBytes.length);
            return Optional.of(new String(Base64.getEncoder().encode(bytes), DEFAULT_ENCODE));
        } catch (IOException | GeneralSecurityException e) {
            return Optional.empty();
        }
    }
@Test
    void encrypt() {
        Optional<String> optional = AesUtil.generateKey();
        Assertions.assertTrue(optional.isPresent());
        String key = optional.get();
        Optional<String> encryptTextOptional = AesUtil.encrypt(key, TEXT);
        Assertions.assertTrue(encryptTextOptional.isPresent());
        Optional<String> decryptTextOptional = AesUtil.decrypt(key, encryptTextOptional.get());
        Assertions.assertTrue(decryptTextOptional.isPresent());
        Assertions.assertEquals(decryptTextOptional.get(), TEXT);
    }