AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
AnCH UUID library documentation

Introduction

AnCH UUID library aims to provide facilities for generating and parsing UUID.

Prerequisites

AnCH UUID is a standalone library as long as you only parse UUID or generate random UUID.
For generating MD5 and SHA1 UUIDs, AnCH cryptography library documentation anch-crypto library is required.
For generating MAC UUIDs, anch-device library is required.

Installation

CMake target anch::uuid:

find_package(Anch REQUIRED)
target_link_libraries(my-app PRIVATE anch::uuid)

See installation.

Conception

AnCH UUID library contains only one class: UUID.
Each UUID version should have a provider for UUID generation. This library provides the random version implementation (version 4).

AnCH cryptography library documentation anch-crypto library provides MD5 (version 3) and SHA1 (version 5) implementations. They have to be registered to be used:

anch-device library provides MAC address (version 1) implementation. It has to be registered to be used:

Examples

#include "uuid.hpp"
#include "crypto/hash/sha1.hpp"
#include <iostream>
int
main() {
anch::UUID random = anch::UUID::random(); // version 4
std::cout << random << std::endl;
anch::UUID parsed("550e8400-e29b-41d4-a716-446655440000"); // std::invalid_argument when invalid
std::cout << parsed.toString() << " version " << static_cast<int>(parsed.getVersion()) << std::endl;
anch::crypto::registerSHA1UUIDProvider(); // version 5 provider (anch-crypto)
std::cout << named << " " << (named == anch::UUID::generateUUID(anch::UUID::Version::SHA1_HASH, "anch-framework")) << std::endl;
return 0;
}