Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating sha1 ids from GUID string, #87

Open
MichaelLudeo opened this issue May 20, 2024 · 0 comments
Open

Generating sha1 ids from GUID string, #87

MichaelLudeo opened this issue May 20, 2024 · 0 comments

Comments

@MichaelLudeo
Copy link

MichaelLudeo commented May 20, 2024

Hi.
I am using boost to generate uid like this:

boost::uuids::name_generator_sha1 generator(boost::uuids::ns::dns());
boost::uuids::uuid machineIdUUID = generator(info.c_str());

Where info contains a string in format "MTI-PC-15179-54281-4576-46682c" which is made out of:

PC name: "MTI-PC"

And the rest four blocks of numbers are some other unique ids of hardware modules in the PC.
Boost takes the above string in and returns GUID.

How do I do the same thing but with stduuid?
In the examples I found this:

   uuids::uuid_name_generator dgen(uuids::uuid::from_string("47183823-2574-4bfd-b411-99ed177d3e43").value());
   auto id1 = dgen("john");
   REQUIRE(!id1.is_nil());
   REQUIRE(id1.version() == uuids::uuid_version::name_based_sha1);

What string should go into dgen() in this case?Some arbitraryGUI string? If I put into it "MTI-PC-15179-54281-4576-46682c" it crashes at .value() return.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant