1 // 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 12 namespace base { 13 14 // static CreateRandom()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 ToString() const24std::string Token::ToString() const { 25 return base::StringPrintf("%016" PRIX64 "%016" PRIX64, high_, low_); 26 } 27 28 } // namespace base 29