blob: c0a06f8858e3637aace7ebd03287e18b095e35e4 [file] [log] [blame]
[email protected]7e49ad32012-06-14 14:22:071// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]3469e7e2010-10-14 20:34:592// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]7e49ad32012-06-14 14:22:075#ifndef BASE_GUID_H_
6#define BASE_GUID_H_
[email protected]3469e7e2010-10-14 20:34:597
avi9b6f42932015-12-26 22:15:148#include <stdint.h>
9
[email protected]3469e7e2010-10-14 20:34:5910#include <string>
11
[email protected]7e49ad32012-06-14 14:22:0712#include "base/base_export.h"
[email protected]3469e7e2010-10-14 20:34:5913#include "build/build_config.h"
14
[email protected]7e49ad32012-06-14 14:22:0715namespace base {
[email protected]3469e7e2010-10-14 20:34:5916
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.
sungmann.cho8b0ae1b2014-09-29 06:39:1819// The POSIX implementation uses pseudo random number generation to create
[email protected]3469e7e2010-10-14 20:34:5920// the GUID. The Windows implementation uses system services.
[email protected]7e49ad32012-06-14 14:22:0721BASE_EXPORT std::string GenerateGUID();
[email protected]3469e7e2010-10-14 20:34:5922
[email protected]d3d728e92010-10-20 03:24:5523// Returns true if the input string conforms to the GUID format.
[email protected]7e49ad32012-06-14 14:22:0724BASE_EXPORT bool IsValidGUID(const std::string& guid);
[email protected]d3d728e92010-10-20 03:24:5525
[email protected]3469e7e2010-10-14 20:34:5926#if defined(OS_POSIX)
27// For unit testing purposes only. Do not use outside of tests.
avi9b6f42932015-12-26 22:15:1428BASE_EXPORT std::string RandomDataToGUIDString(const uint64_t bytes[2]);
[email protected]3469e7e2010-10-14 20:34:5929#endif
30
[email protected]4461e9ad2013-09-27 08:52:2931} // namespace base
[email protected]3469e7e2010-10-14 20:34:5932
[email protected]7e49ad32012-06-14 14:22:0733#endif // BASE_GUID_H_