semvec/pypi-packages huggingface dataset:
klingon-serial 0.1.15
Get a globally unique serial
License: MIT
Requires Python: >=3.9

# Klingon Serial Python Module
[![klingon-serial unit tests](https://github.com/djh00t/module_klingon_serial/actions/workflows/klingon-serial-unit-tests.yaml/badge.svg)](https://github.com/djh00t/module_klingon_serial/actions/workflows/klingon-serial-unit-tests.yaml)
[![Pre-PR Merge CI](https://github.com/djh00t/module_klingon_serial/actions/workflows/pre-pr-merge.yaml/badge.svg)](https://github.com/djh00t/module_klingon_serial/actions/workflows/pre-pr-merge.yaml) [![.github/workflows/post-pr-merge.yaml](https://github.com/djh00t/module_klingon_serial/actions/workflows/post-pr-merge.yaml/badge.svg)](https://github.com/djh00t/module_klingon_serial/actions/workflows/post-pr-merge.yaml)
## Overview

The `klingon_serial` Python module is designed to generate a unique hexadecimal
serial number, avoiding serial conflicts in a distributed environment. The
serial number is a concatenation of the machine's MAC address, the process ID
(PID), and the current time in epoch format with millisecond precision. The
module aims to offer a robust method for generating serials that are virtually collision-free.

## Installation

To install the module, you can use `pip`:

```bash
pip install klingon-serial
```

## Serial Components

1. **MAC Address**: A unique identifier assigned to network interfaces for communications. 12 characters in hexadecimal.
2. **Process ID (PID)**: Unique ID for each running process. Up to 6 characters in hexadecimal.
3. **Timestamp**: Millisecond-precision epoch time. Up to 10 characters in hexadecimal.

These components are concatenated to form a unique serial number.

## Usage

Here is how you can use the `klingon_serial` module:

```python
import klingon_serial

# Generate a unique serial number
unique_serial = klingon_serial.generate()
print(f"Generated Serial: {unique_serial}")
```

## Serial Number Structure

The generated serial number has the following structure:

```
[ 12 characters MAC ][ Up to 6 characters PID ][ 10 characters Timestamp ]
```

### Example

An example serial number might look like this:

```
02C3F642A1EC3A4B9B0985F53E
```

## Testing

To run the test suite, you can use:

```bash
python -m unittest discover -s tests
```

## Contributing

Feel free to fork this repository and submit pull requests for improvements or additional features.