Get a globally unique serial
Project description
Klingon Serial Python Module
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
:
pip install klingon-serial
Serial Components
- MAC Address: A unique identifier assigned to network interfaces for communications. 12 characters in hexadecimal.
- Process ID (PID): Unique ID for each running process. Up to 6 characters in hexadecimal.
- 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:
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:
python -m unittest discover -s tests
Contributing
Feel free to fork this repository and submit pull requests for improvements or additional features.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for klingon_serial-0.1.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1783858c9154ef73c68ebef7930f6ab3add22d00ae6b0706e2319bf28f628368 |
|
MD5 | 31e06ac5c316214ba71c18f3ec1dce5e |
|
BLAKE2b-256 | d0daa3c2c00f2a0f9b9d50a6b3cf59974c84e67ed43842f1299115b377040354 |