BLDEuuid is a custom UUID generator that creates unique identifiers based on an input string. The UUID consists of three parts:
- First 10 bytes: Derived from the input string.
- Next 7 bytes: A BLAKE2b hash of the input string combined with the current timestamp.
- 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.
- 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).
To use BLDEuuid, ensure that your project includes the necessary dependencies.
#include <BLDEuuid.h>#include <iostream>
#include <BLDEuuid.h>
int main() {
BLDEuuid uuid = BLDEuuid::generateuuid("example");
std::cout << "Generated UUID: " << uuid << std::endl;
return 0;
}Generated 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;To clone a repository you can use the git command:
git clone --recursive https://github.com/BlackDevers/BLDEuuid.gitor
git submodule add https://github.com/BlackDevers/BLDEuuid.git your/path/to/submodule_BLDEuuidIt is also possible to simply download a zip archive from github
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+)
mkdir build && cd buildcmake .. -DCMAKE_BUILD_TYPE=Debugcmake .. -DCMAKE_BUILD_TYPE=ReleaseThe Release mode enables the -O3 -march=native -DNDEBUG optimization flags.
cmake --build .After a successful build, the library will be located in build/lib.
If you want to install the library system-wide:
sudo cmake --install .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)If the library is not installed, you can include it via add_subdirectory().
MyProject/
│── CMakeLists.txt
│── src/
│── third_party/
│ └── BLDEuuid/ <-- cloned repository
add_subdirectory(third_party/BLDEuuid)
target_link_libraries(MyProject PRIVATE BLDEuuid)Some clarifications on the project:
- Installation in Windows is missing
- Also the build for windows may be unsuccessful, contact issues
BLDEuuid — это кастомный генератор UUID, который создаёт уникальные идентификаторы на основе входной строки. UUID состоит из трёх частей:
- Первые 10 байт: получены из входной строки.
- Следующие 7 байт: хеш BLAKE2b входной строки, объединённой с текущим временным штампом.
- Последние 2 байта: сумма даты на момент генерации (yyyy+mm+dd).
Сгенерированный UUID имеет формат:
xxxxxxxxxx-xxxxxxx-yyyy
где:
xxxxxxxxxx— первые 10 байт из входной строки,xxxxxxx— хешированная «соль»,yyyy— сумма даты на момент генерции.
- Генерирует детерминированные UUID на основе входных строк.
- Использует BLAKE2b для хеширования.
- Включает текущую дату в идентификатор.
- Поддерживает перегрузку операторов для удобства использования.
- Предоставляет литералы пользователя (
"example"_uuid).
Для использования BLDEuuid убедитесь, что ваш проект включает все необходимые зависимости.
#include <BLDEuuid.h>#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.
Перед началом убедитесь, что у вас установлены:
- CMake (версия 3.20 или новее)
- Компилятор с поддержкой C++20 (например, GCC 10+, Clang 10+, MSVC 2019+)
mkdir build && cd buildcmake .. -DCMAKE_BUILD_TYPE=Debugcmake .. -DCMAKE_BUILD_TYPE=ReleaseРежим Release включает оптимизационные флаги -O3 -march=native -DNDEBUG.
cmake --build .После успешной сборки библиотека будет находиться в build.
Если необходимо установить библиотеку в систему:
sudo cmake --install .Если библиотека была установлена с помощью cmake --install, можно подключить её следующим образом:
find_package(BLDEuuid REQUIRED)
target_link_libraries(MyProject PRIVATE BLDEuuid::BLDEuuid)Если библиотека не была установлена, её можно подключить через add_subdirectory().
MyProject/
│── CMakeLists.txt
│── src/
│── third_party/
│ └── BLDEuuid/ <-- клонированный репозиторий
add_subdirectory(third_party/BLDEuuid)
target_link_libraries(MyProject PRIVATE BLDEuuid)Некоторые пояснения по проекту:
- Установка в Windows отсутствует.
- Также сборка под Windows может быть неудачной, в этом случае обратитесь в issues.