blob: a43a2239893be59d0969ed2255080899f50f9343 [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
8#include <string>
9
10#include "base/base_export.h"
11#include "base/basictypes.h"
Vitaly Buka8750b272015-08-18 18:39:08 -070012#include "base/build/build_config.h"
Vitaly Bukacbed2062015-08-17 12:54:05 -070013
14namespace base {
15
16// Generate a 128-bit random GUID of the form: "%08X-%04X-%04X-%04X-%012llX".
17// If GUID generation fails an empty string is returned.
18// The POSIX implementation uses pseudo random number generation to create
19// the GUID. The Windows implementation uses system services.
Vitaly Buka60b8f002015-08-20 13:47:48 -070020std::string GenerateGUID();
Vitaly Bukacbed2062015-08-17 12:54:05 -070021
Vitaly Bukacbed2062015-08-17 12:54:05 -070022#if defined(OS_POSIX)
23// For unit testing purposes only. Do not use outside of tests.
Vitaly Buka60b8f002015-08-20 13:47:48 -070024std::string RandomDataToGUIDString(const uint64 bytes[2]);
Vitaly Bukacbed2062015-08-17 12:54:05 -070025#endif
26
27} // namespace base
28
29#endif // BASE_GUID_H_