| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/rand_util.h" | 5 #include "base/rand_util.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 uint64 random_int; | 64 uint64 random_int; |
| 65 size_t random_int_size = sizeof(random_int); | 65 size_t random_int_size = sizeof(random_int); |
| 66 for (size_t i = 0; i < output_length; i += random_int_size) { | 66 for (size_t i = 0; i < output_length; i += random_int_size) { |
| 67 random_int = base::RandUint64(); | 67 random_int = base::RandUint64(); |
| 68 size_t copy_count = std::min(output_length - i, random_int_size); | 68 size_t copy_count = std::min(output_length - i, random_int_size); |
| 69 memcpy(((uint8*)output) + i, &random_int, copy_count); | 69 memcpy(((uint8*)output) + i, &random_int, copy_count); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 std::string RandBytesAsString(size_t length) { | 73 std::string RandBytesAsString(size_t length) { |
| 74 DCHECK_GT(length, 0u); |
| 74 std::string result; | 75 std::string result; |
| 75 RandBytes(WriteInto(&result, length + 1), length); | 76 RandBytes(WriteInto(&result, length + 1), length); |
| 76 return result; | 77 return result; |
| 77 } | 78 } |
| 78 | 79 |
| 79 } // namespace base | 80 } // namespace base |
| OLD | NEW |