---
title: llarp/win32/guid.hpp

---

# llarp/win32/guid.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::win32](Namespaces/namespacellarp_1_1win32.md)**  |




## Source code

```cpp
#pragma once

#include <llarp/crypto/crypto.hpp>
#include <windows.h>
#include <type_traits>

namespace llarp::win32
{
  template <typename Data>
  inline GUID
  MakeDeterministicGUID(Data data)
  {
    ShortHash h{};
    auto hash = [&h](auto data) { CryptoManager::instance()->shorthash(h, data); };

    if constexpr (std::is_same_v<Data, std::string>)
      hash(llarp_buffer_t{reinterpret_cast<const byte_t*>(data.data()), data.size()});
    else
      hash(llarp_buffer_t{data});
    GUID guid{};
    std::copy_n(
        h.begin(), std::min(sizeof(GUID), sizeof(ShortHash)), reinterpret_cast<uint8_t*>(&guid));
    return guid;
  }
}  // namespace llarp::win32
```


-------------------------------

Updated on 2023-01-20 at 18:12:19 +0000
