code: public static String publicKey2String(PublicKey key) {
          X509EncodedKeySpec spec = new X509EncodedKeySpec(key.getEncoded());
          return new String(Base64.getEncoder().encode(spec.getEncoded()), StandardCharsets.UTF_8);
      }
docs: This is what you can share.
  @param key the key
  @return base 64 encoded string of the X509 spec