public static final InputStream createKeyset(
      KeyTemplate keyTemplate, String outFormat, String masterKeyUri, String credentialPath)
      throws GeneralSecurityException, IOException {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    createKeyset(outputStream, outFormat, masterKeyUri, credentialPath, keyTemplate);
    return new ByteArrayInputStream(outputStream.toByteArray());
  }
Creates a keyset that contains a single key of template {@code keyTemplate}, encrypts it using
{@code credentialPath} and {@code masterKeyUri}, then encodes it in {@code outFormat}.

@return an input stream containing the resulting encrypted keyset.
@throws GeneralSecurityException if failed to encrypt keyset.
tools/tinkey/src/main/java/com/google/crypto/tink/tinkey/TinkeyUtil.java