Skip to contents

Generate a random UUID (Universally Unique Identifier) that complies to what RFC4122 prescribes. Such a value is also known as a version 4 UUID.

Usage

uuid()

uuid_raw()

uuid_is(x)

Arguments

x

An R object.

Value

uuid() returns a character of length 1 containing exactly 36 characters: 32 hexadecimal characters and 4 hyphens (used as separators).

uuid_raw() returns a raw vector of length 16.

uuid_is() returns a logical vector having the same length as x. It checks whether its elements are valid version 4 (variant 1) UUIDs or not. It returns FALSE for any other kind of UUID.

Details

uuid() calls uuid_raw() and formats its output accordingly.

Pseudo-random bytes are generated with sample() whenever uuid_raw() is called. This is most likely done before runtime when Translator objects are created. uuid_raw() samples values in the [0, 255] range with replacement and converts them to raw values. The user must ensure that the underlying seed is appropriate when generating UUIDs. See set.seed() for more information.

Note

UUIDs are designed to be globally unique (collisions are extremely unlikely) and are sometimes called GUIDs (Globally Unique Identifiers). There are several UUID versions with slightly different purposes.

Package transltr uses random identifiers (version 4/variant 1, also known as DCE 1.1, ISO/IEC 11578:1996).

Examples

uuid()
uuid_raw()
uuid_is(uuid())      ## TRUE
uuid_is(uuid_raw())  ## FALSE, uuid_raw() does not return a string.