| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_RAND_UTIL_H_ | 5 #ifndef BASE_RAND_UTIL_H_ |
| 6 #define BASE_RAND_UTIL_H_ | 6 #define BASE_RAND_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // the range [0, 1). Thread-safe. | 32 // the range [0, 1). Thread-safe. |
| 33 BASE_EXPORT double BitsToOpenEndedUnitInterval(uint64 bits); | 33 BASE_EXPORT double BitsToOpenEndedUnitInterval(uint64 bits); |
| 34 | 34 |
| 35 // Fills |output_length| bytes of |output| with random data. | 35 // Fills |output_length| bytes of |output| with random data. |
| 36 // | 36 // |
| 37 // WARNING: | 37 // WARNING: |
| 38 // Do not use for security-sensitive purposes. | 38 // Do not use for security-sensitive purposes. |
| 39 // See crypto/ for cryptographically secure random number generation APIs. | 39 // See crypto/ for cryptographically secure random number generation APIs. |
| 40 BASE_EXPORT void RandBytes(void* output, size_t output_length); | 40 BASE_EXPORT void RandBytes(void* output, size_t output_length); |
| 41 | 41 |
| 42 // Fills a string of length |length| with with random data and returns it. | 42 // Fills a string of length |length| with random data and returns it. |
| 43 // |length| should be nonzero. | 43 // |length| should be nonzero. |
| 44 // | 44 // |
| 45 // Note that this is a variation of |RandBytes| with a different return type. | 45 // Note that this is a variation of |RandBytes| with a different return type. |
| 46 // The returned string is likely not ASCII/UTF-8. Use with care. |
| 46 // | 47 // |
| 47 // WARNING: | 48 // WARNING: |
| 48 // Do not use for security-sensitive purposes. | 49 // Do not use for security-sensitive purposes. |
| 49 // See crypto/ for cryptographically secure random number generation APIs. | 50 // See crypto/ for cryptographically secure random number generation APIs. |
| 50 BASE_EXPORT std::string RandBytesAsString(size_t length); | 51 BASE_EXPORT std::string RandBytesAsString(size_t length); |
| 51 | 52 |
| 52 #if defined(OS_POSIX) | 53 #if defined(OS_POSIX) |
| 53 BASE_EXPORT int GetUrandomFD(); | 54 BASE_EXPORT int GetUrandomFD(); |
| 54 #endif | 55 #endif |
| 55 | 56 |
| 56 } // namespace base | 57 } // namespace base |
| 57 | 58 |
| 58 #endif // BASE_RAND_UTIL_H_ | 59 #endif // BASE_RAND_UTIL_H_ |
| OLD | NEW |