public static Optional<String> encrypt(String publicKey, String text) {
        try {
            Cipher cipher = Cipher.getInstance(RSA_PADDING);
            byte[] publicKeyBytes = Base64.getDecoder().decode(publicKey.getBytes(DEFAULT_ENCODE));
            X509EncodedKeySpec encodedKeySpec = new X509EncodedKeySpec(publicKeyBytes);
            KeyFactory keyFactory = KeyFactory.getInstance(ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, keyFactory.generatePublic(encodedKeySpec));
            return Optional.ofNullable(new String(Base64.getEncoder().encode(cipher.doFinal(
                    text.getBytes(DEFAULT_ENCODE))), DEFAULT_ENCODE));
        } catch (IOException | GeneralSecurityException e) {
            return Optional.empty();
        }
    }
@Test
    void encrypt() {
        Optional<String[]> optional = RsaUtil.generateKey();
        Assertions.assertTrue(optional.isPresent());
        String[] key = optional.get();
        Optional<String> encryptTextOptional = RsaUtil.encrypt(key[1], TEXT);
        Optional<String> decryptTextOptional = RsaUtil.decrypt(key[0], encryptTextOptional.get());
        Assert.assertEquals(decryptTextOptional.get(), TEXT);
    }