Skip to content

borz7zy/BLDEuuid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlackDevers uuid

Navigation / Навигация

🌍 English 🇷🇺 Русский
Overview Обзор
Features Возможности
Example of use Пример использования
Clone repository, build, install Клонирование репозитория, сборка, установка
1️⃣ Requirements 1️⃣ Требования
2️⃣ Building the Project 2️⃣ Сборка проекта
3️⃣ Installation (Optional) 3️⃣ Установка (опционально)
4️⃣ Integrating into Another Project 4️⃣ Интеграция в другой проект
5️⃣ Clarifications 5️⃣ Разъяснения

English

Overview

BLDEuuid is a custom UUID generator that creates unique identifiers based on an input string. The UUID consists of three parts:

  1. First 10 bytes: Derived from the input string.
  2. Next 7 bytes: A BLAKE2b hash of the input string combined with the current timestamp.
  3. Final 2 bytes: sum of date at the time of generation (yyyy+mm+dd).

The generated UUID is formatted as:

xxxxxxxxxx-xxxxxxx-yyyy

where:

  • xxxxxxxxxx - represents the first 10 bytes from the input string,
  • xxxxxxx - represents the hashed salt,
  • yyyy - sum of the date at the time of generation.

Features

  • Generates deterministic UUIDs based on input strings.
  • Uses BLAKE2b for hashing.
  • Includes the current date as part of the identifier.
  • Supports operator overloading for easy usage.
  • Provides a user-defined literal ("example"_uuid).

Example of use

To use BLDEuuid, ensure that your project includes the necessary dependencies.

#include <BLDEuuid.h>

Creating a UUID

#include <iostream>
#include <BLDEuuid.h>

int main() {
    BLDEuuid uuid = BLDEuuid::generateuuid("example");
    std::cout << "Generated UUID: " << uuid << std::endl;
    return 0;
}
Output Example:
Generated UUID: 6578616d70-abc1234-2050

Using User-Defined Literals

BLDEuuid uuid = "example"_uuid;
std::cout << uuid << std::endl;

Setting Custom Values

BLDEuuid uuid;
uuid.setPart1("edited 1");
uuid.setPart2("edited 2");
uuid.setPart3(3000);
std::cout << uuid.str() << std::endl;

Clone repository, build, install

To clone a repository you can use the git command:

git clone --recursive https://github.com/BlackDevers/BLDEuuid.git

or

git submodule add https://github.com/BlackDevers/BLDEuuid.git your/path/to/submodule_BLDEuuid

It is also possible to simply download a zip archive from github

1. Requirements

Before starting, make sure you have:

  • CMake (version 3.20 or newer)
  • A C++20-compatible compiler (e.g., GCC 10+, Clang 10+, MSVC 2019+)

2. Building the Project

2.1 Create a Build Directory

mkdir build && cd build

2.2 Generate Build Files

Debug Build
cmake .. -DCMAKE_BUILD_TYPE=Debug
Release Build
cmake .. -DCMAKE_BUILD_TYPE=Release

The Release mode enables the -O3 -march=native -DNDEBUG optimization flags.

2.3 Compile the Project

cmake --build .

After a successful build, the library will be located in build/lib.

3. Installation (Optional)

If you want to install the library system-wide:

sudo cmake --install .

4. Integrating into Another Project

4.1 Using as an Installed Library (find_package)

If the library was installed using cmake --install, you can link it as follows:

find_package(BLDEuuid REQUIRED)
target_link_libraries(MyProject PRIVATE BLDEuuid::BLDEuuid)

4.2 Adding as a Subdirectory

If the library is not installed, you can include it via add_subdirectory().

4.2.1 Project Structure
MyProject/
│── CMakeLists.txt
│── src/
│── third_party/
│   └── BLDEuuid/  <-- cloned repository
4.2.2 Updating CMakeLists.txt
add_subdirectory(third_party/BLDEuuid)
target_link_libraries(MyProject PRIVATE BLDEuuid)

5. Clarifications

Some clarifications on the project:

  • Installation in Windows is missing
  • Also the build for windows may be unsuccessful, contact issues

Русский

Обзор

BLDEuuid — это кастомный генератор UUID, который создаёт уникальные идентификаторы на основе входной строки. UUID состоит из трёх частей:

  1. Первые 10 байт: получены из входной строки.
  2. Следующие 7 байт: хеш BLAKE2b входной строки, объединённой с текущим временным штампом.
  3. Последние 2 байта: сумма даты на момент генерации (yyyy+mm+dd).

Сгенерированный UUID имеет формат:

xxxxxxxxxx-xxxxxxx-yyyy

где:

  • xxxxxxxxxx — первые 10 байт из входной строки,
  • xxxxxxx — хешированная «соль»,
  • yyyy — сумма даты на момент генерции.

Возможности

  • Генерирует детерминированные UUID на основе входных строк.
  • Использует BLAKE2b для хеширования.
  • Включает текущую дату в идентификатор.
  • Поддерживает перегрузку операторов для удобства использования.
  • Предоставляет литералы пользователя ("example"_uuid).

Пример использования

Для использования BLDEuuid убедитесь, что ваш проект включает все необходимые зависимости.

#include <BLDEuuid.h>

Создание UUID

#include <iostream>
#include <BLDEuuid.h>

int main() {
    BLDEuuid uuid = BLDEuuid::generateuuid("example");
    std::cout << "Сгенерированный UUID: " << uuid << std::endl;
    return 0;
}
Пример вывода:
Сгенерированный UUID: 6578616d70-abc1234-2050

Использование пользовательских литералов

BLDEuuid uuid = "example"_uuid;
std::cout << uuid << std::endl;

Установка пользовательских значений

BLDEuuid uuid;
uuid.setPart1("edited 1");
uuid.setPart2("edited 2");
uuid.setPart3(3000);
std::cout << uuid.str() << std::endl;

Клонирование репозитория, сборка, установка

Для клонирования репозитория используйте команду git:

git clone --recursive https://github.com/BlackDevers/BLDEuuid.git

или

git submodule add --recursive https://github.com/BlackDevers/BLDEuuid.git your/path/to/submodule_BLDEuuid

Также можно просто скачать ZIP-архив с GitHub.

1. Требования

Перед началом убедитесь, что у вас установлены:

  • CMake (версия 3.20 или новее)
  • Компилятор с поддержкой C++20 (например, GCC 10+, Clang 10+, MSVC 2019+)

2. Сборка проекта

2.1 Создание каталога для сборки

mkdir build && cd build

2.2 Генерация файлов сборки

Отладочная сборка
cmake .. -DCMAKE_BUILD_TYPE=Debug
Релизная сборка
cmake .. -DCMAKE_BUILD_TYPE=Release

Режим Release включает оптимизационные флаги -O3 -march=native -DNDEBUG.

2.3 Компиляция проекта

cmake --build .

После успешной сборки библиотека будет находиться в build.

3. Установка (опционально)

Если необходимо установить библиотеку в систему:

sudo cmake --install .

4. Интеграция в другой проект

4.1 Использование установленной библиотеки (find_package)

Если библиотека была установлена с помощью cmake --install, можно подключить её следующим образом:

find_package(BLDEuuid REQUIRED)
target_link_libraries(MyProject PRIVATE BLDEuuid::BLDEuuid)

4.2 Добавление как подкаталога

Если библиотека не была установлена, её можно подключить через add_subdirectory().

4.2.1 Структура проекта
MyProject/
│── CMakeLists.txt
│── src/
│── third_party/
│   └── BLDEuuid/  <-- клонированный репозиторий
4.2.2 Обновление CMakeLists.txt
add_subdirectory(third_party/BLDEuuid)
target_link_libraries(MyProject PRIVATE BLDEuuid)

5. Разъяснения

Некоторые пояснения по проекту:

  • Установка в Windows отсутствует.
  • Также сборка под Windows может быть неудачной, в этом случае обратитесь в issues.

About

custom uuid library on c++20

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • CMake 70.2%
  • C++ 29.8%