OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 "mojo/edk/system/unique_identifier.h" |
| 6 |
| 7 #include <ostream> |
| 8 |
| 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "crypto/random.h" |
| 11 |
| 12 namespace mojo { |
| 13 namespace system { |
| 14 |
| 15 std::ostream& operator<<(std::ostream& out, |
| 16 const UniqueIdentifier& unique_identifier) { |
| 17 return out << base::HexEncode(unique_identifier.data_, |
| 18 sizeof(unique_identifier.data_)); |
| 19 } |
| 20 |
| 21 // static |
| 22 UniqueIdentifier UniqueIdentifier::Generate() { |
| 23 UniqueIdentifier rv; |
| 24 crypto::RandBytes(rv.data_, sizeof(rv.data_)); |
| 25 return rv; |
| 26 } |
| 27 |
| 28 } // namespace system |
| 29 } // namespace mojo |
OLD | NEW |