blob: 1bb9ab2502ce2dc73f597273377b81dd13ce6a7a [file] [log] [blame]
Vitaly Bukacbed2062015-08-17 12:54:05 -07001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_GUID_H_
6#define BASE_GUID_H_
7
Alex Vakulenko674f0eb2016-01-20 08:10:48 -08008#include <stdint.h>
9
Vitaly Bukacbed2062015-08-17 12:54:05 -070010#include <string>
11
12#include "base/base_export.h"
Alex Vakulenkof1fa8be2015-12-08 12:38:56 -080013#include "build/build_config.h"
Vitaly Bukacbed2062015-08-17 12:54:05 -070014
15namespace base {
16
17// Generate a 128-bit random GUID of the form: "%08X-%04X-%04X-%04X-%012llX".
18// If GUID generation fails an empty string is returned.
19// The POSIX implementation uses pseudo random number generation to create
20// the GUID. The Windows implementation uses system services.
Vitaly Buka60b8f002015-08-20 13:47:48 -070021std::string GenerateGUID();
Vitaly Bukacbed2062015-08-17 12:54:05 -070022
Vitaly Bukacbed2062015-08-17 12:54:05 -070023#if defined(OS_POSIX)
24// For unit testing purposes only. Do not use outside of tests.
Alex Vakulenko674f0eb2016-01-20 08:10:48 -080025std::string RandomDataToGUIDString(const uint64_t bytes[2]);
Vitaly Bukacbed2062015-08-17 12:54:05 -070026#endif
27
28} // namespace base
29
30#endif // BASE_GUID_H_