OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... | |
32 // We generate base64 values so that they will be printable. | 32 // We generate base64 values so that they will be printable. |
33 // Return false if the random number generator failed. | 33 // Return false if the random number generator failed. |
34 bool CreateRandomString(size_t length, std::string* str); | 34 bool CreateRandomString(size_t length, std::string* str); |
35 | 35 |
36 // Generates a (cryptographically) random string of the given length, | 36 // Generates a (cryptographically) random string of the given length, |
37 // with characters from the given table. Return false if the random | 37 // with characters from the given table. Return false if the random |
38 // number generator failed. | 38 // number generator failed. |
39 bool CreateRandomString(size_t length, const std::string& table, | 39 bool CreateRandomString(size_t length, const std::string& table, |
40 std::string* str); | 40 std::string* str); |
41 | 41 |
42 // Generates (cryptographically) random data of the given length. | |
43 // Return false if the random number generator failed. | |
44 bool CreateRandomData(size_t length, void* data); | |
mattdr
2016/05/10 22:29:13
Let's avoid the buffer pointer and use a vector<ch
joachim
2016/05/10 23:09:44
Done (used std::string).
| |
45 | |
42 // Generates a (cryptographically) random UUID version 4 string. | 46 // Generates a (cryptographically) random UUID version 4 string. |
43 std::string CreateRandomUuid(); | 47 std::string CreateRandomUuid(); |
44 | 48 |
45 // Generates a random id. | 49 // Generates a random id. |
46 uint32_t CreateRandomId(); | 50 uint32_t CreateRandomId(); |
47 | 51 |
48 // Generates a 64 bit random id. | 52 // Generates a 64 bit random id. |
49 uint64_t CreateRandomId64(); | 53 uint64_t CreateRandomId64(); |
50 | 54 |
51 // Generates a random id > 0. | 55 // Generates a random id > 0. |
52 uint32_t CreateRandomNonZeroId(); | 56 uint32_t CreateRandomNonZeroId(); |
53 | 57 |
54 // Generates a random double between 0.0 (inclusive) and 1.0 (exclusive). | 58 // Generates a random double between 0.0 (inclusive) and 1.0 (exclusive). |
55 double CreateRandomDouble(); | 59 double CreateRandomDouble(); |
56 | 60 |
57 } // namespace rtc | 61 } // namespace rtc |
58 | 62 |
59 #endif // WEBRTC_BASE_HELPERS_H_ | 63 #endif // WEBRTC_BASE_HELPERS_H_ |
OLD | NEW |