blob: e7ad896713919ce0385700499099fc4cb02a7153 [file] [log] [blame]
Ken Rockot8c6991c72018-11-07 21:23:191// Copyright 2018 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#include "base/token.h"
6
7#include <inttypes.h>
8
9#include "base/rand_util.h"
10#include "base/strings/stringprintf.h"
11
12namespace base {
13
14// static
15Token Token::CreateRandom() {
16 Token token;
17
18 // Use base::RandBytes instead of crypto::RandBytes, because crypto calls the
19 // base version directly, and to prevent the dependency from base/ to crypto/.
20 base::RandBytes(&token, sizeof(token));
21 return token;
22}
23
24std::string Token::ToString() const {
25 return base::StringPrintf("%016" PRIX64 "%016" PRIX64, high_, low_);
26}
27
28} // namespace base