Skip to content

UUID

The rite.crypto.uuid submodule contains helpers for generating, transforming, and validating UUID values.

Identity Module

This module provides unique identifier generation similar to Python's uuid module.

Functions will include: - UUID generation and utilities

Example

from rite.identity import generate_uuid generate_uuid() 'a1b2c3d4-e5f6-...'

Functions

is_valid_uuid(uuid_to_test: str, version: int = 4) -> bool

Check if uuid_to_test is a valid UUID.

Parameters:

Name Type Description Default
uuid_to_test str

String to validate as UUID

required
version int

UUID version to check (1, 2, 3, or 4)

4

Returns:

Type Description
bool

True if valid UUID, False otherwise

Example

is_valid_uuid('550e8400-e29b-41d4-a716-446655440000') True is_valid_uuid('invalid') False

Modules

uuid_from_name

Rite - UUID Module

Functions

from_name(namespace, name)

Generates a UUID based on a namespace and a name.

Parameters:

Name Type Description Default
namespace UUID

The namespace UUID.

required
name str

The name from which to generate the UUID.

required
Returns
uuid.UUID: A UUID generated from the namespace and name.

uuid_get_version

Rite - UUID Module

Functions

get_version(uuid_obj)

Extracts the version of a UUID.

Parameters:

Name Type Description Default
uuid_obj UUID

The UUID object.

required
Returns
int: The version number of the UUID.

uuid_hex

UUID Hexadecimal Generation

Generate random UUIDs as hexadecimal strings.

Functions

uuid_hex() -> str

Generate a random UUID and return it as a 32-character hexadecimal string.

Returns:

Type Description
str

UUID as a 32-character hexadecimal string (no hyphens)

Example

len(uuid_hex()) 32

uuid_is_random

Rite - UUID Module

Functions

is_random_uuid(uuid_obj)

Checks if the UUID is randomly generated (UUID4).

Parameters:

Name Type Description Default
uuid_obj UUID

The UUID object.

required
Returns
bool: True if the UUID is a random UUID, False otherwise.

uuid_is_valid

UUID Validation

Validate UUID strings.

Functions

is_valid_uuid(uuid_to_test: str, version: int = 4) -> bool

Check if uuid_to_test is a valid UUID.

Parameters:

Name Type Description Default
uuid_to_test str

String to validate as UUID

required
version int

UUID version to check (1, 2, 3, or 4)

4

Returns:

Type Description
bool

True if valid UUID, False otherwise

Example

is_valid_uuid('550e8400-e29b-41d4-a716-446655440000') True is_valid_uuid('invalid') False

uuid_random

UUID Object Generation

Generate random UUID objects.

Functions

uuid_random() -> uuid.UUID

Generate a random UUID (UUID4).

Returns:

Type Description
UUID

A randomly generated UUID object

Example

isinstance(uuid_random(), uuid.UUID) True

uuid_string

UUID String Generation

Generate random UUIDs as formatted strings.

Functions

uuid_string() -> str

Generate a random UUID and return it as a string in standard form.

Returns:

Type Description
str

UUID as a string in standard form (with hyphens)

Example

'-' in uuid_string() True len(uuid_string()) 36

options: show_root_heading: true show_source: false heading_level: 2