1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CRYPTO_RANDOM_H_ 6 #define CRYPTO_RANDOM_H_ 7 8 #include <stddef.h> 9 10 #include <vector> 11 12 #include "base/containers/span.h" 13 #include "crypto/crypto_export.h" 14 15 namespace crypto { 16 17 // Fills `bytes` with cryptographically-secure random bits. 18 CRYPTO_EXPORT void RandBytes(base::span<uint8_t> bytes); 19 20 // Returns a vector of `length` bytes filled with cryptographically-secure 21 // random bits. 22 CRYPTO_EXPORT std::vector<uint8_t> RandBytesAsVector(size_t length); 23 } 24 25 #endif // CRYPTO_RANDOM_H_ 26