Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Side by Side Diff: base/rand_util.h

Issue 10698177: Added crypto random-number generator (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comment fixes Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/rand_util_posix.cc » ('j') | base/rand_util_posix.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 // std::random_shuffle(myvector.begin(), myvector.end(), base::RandGenerator); 25 // std::random_shuffle(myvector.begin(), myvector.end(), base::RandGenerator);
26 BASE_EXPORT uint64 RandGenerator(uint64 range); 26 BASE_EXPORT uint64 RandGenerator(uint64 range);
27 27
28 // Returns a random double in range [0, 1). Thread-safe. 28 // Returns a random double in range [0, 1). Thread-safe.
29 BASE_EXPORT double RandDouble(); 29 BASE_EXPORT double RandDouble();
30 30
31 // Given input |bits|, convert with maximum precision to a double in 31 // Given input |bits|, convert with maximum precision to a double in
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 cryptographically strong random 35 // Fills |output_length| bytes of |output| with random data.
36 // data. 36 // Use crypto/random for cryptographically random data instead of this function.
37 BASE_EXPORT void RandBytes(void* output, size_t output_length); 37 BASE_EXPORT void RandBytes(void* output, size_t output_length);
38 38
39 // Fills a string of length |length| with with cryptographically strong random 39 // Fills a string of length |length| with with random data and returns it.
40 // data and returns it. |length| should be nonzero. 40 // |length| should be nonzero.
41 //
42 // Use crypto/random for cryptographically random data instead of this function.
41 // 43 //
42 // Note that this is a variation of |RandBytes| with a different return type. 44 // Note that this is a variation of |RandBytes| with a different return type.
43 BASE_EXPORT std::string RandBytesAsString(size_t length); 45 BASE_EXPORT std::string RandBytesAsString(size_t length);
44 46
45 #ifdef OS_POSIX 47 #ifdef OS_POSIX
46 BASE_EXPORT int GetUrandomFD(); 48 BASE_EXPORT int GetUrandomFD();
47 #endif 49 #endif
48 50
49 } // namespace base 51 } // namespace base
50 52
51 #endif // BASE_RAND_UTIL_H_ 53 #endif // BASE_RAND_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/rand_util_posix.cc » ('j') | base/rand_util_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698