GUuid: GLib Reference Manual

## GUuid GUuid — a universally unique identifier |

## Functions

gboolean | g_uuid_string_is_valid ()
gchar * | g_uuid_string_random ()

## Includes

    #include <glib.h>
    #include <glib/gi18n.h>

## Description

A UUID, or Universally unique identifier, is intended to uniquely identify information in a distributed environment. For the definition of UUID, see RFC 4122.

The creation of UUIDs does not require a centralized authority.

UUIDs are of relatively small size (128 bits, or 16 bytes). The common string representation (ex: 1d6c0810-2bd6-45f3-9890-0268422a6f14) needs 37 bytes.

The UUID specification defines 5 versions, and calling `g_uuid_string_random()` will generate a unique (or rather random) UUID of the most common version, version 4.

## Functions

### g_uuid_string_is_valid ()

    gboolean
    g_uuid_string_is_valid (const gchar *str);

Parses the string `str` and verify if it is a UUID.

The function accepts the following syntax:

- simple forms (e.g. `f81d4fae-7dec-11d0-a765-00a0c91e6bf6`)

Note that hyphens are required within the UUID string itself, as per the aforementioned RFC.

#### Parameters

str | a string representing a UUID |

#### Returns

`TRUE` if `str` is a valid UUID, `FALSE` otherwise.

Since: 2.52

### g_uuid_string_random ()

    gchar *
    g_uuid_string_random (void);

Generates a random UUID (RFC 4122 version 4) as a string.

#### Returns

A string that should be freed with `g_free()`.

[transfer full]

Since: 2.52

## Types and Values