public static String serializePublicKey(PublicKey publicKey) throws Exception {
        // Serialize the public key
        byte[] publicKeyBytes = publicKey.getEncoded();
        return Base64.getEncoder().encodeToString(publicKeyBytes);
    }
@Test
    public void testSerializePublicKey() throws Exception {
        KeyPair keyPair = KeyUtil.generateKeyPair("RSA", 2048);
        System.out.println("public key = " + KeyUtil.serializePublicKey(keyPair.getPublic()));
        System.out.println("private key = " + KeyUtil.serializePrivateKey(keyPair.getPrivate()));
    }