userver
C++ Async Framework
Loading...
Searching...
No Matches
random.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/crypto/random.hpp
4
/// @brief Cryptographically-secure randomness
5
6
#
include
<
cstddef
>
7
#
include
<
string
>
8
#
include
<
type_traits
>
9
10
#
include
<
userver
/
utils
/
span
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
crypto {
15
16
namespace
impl {
17
18
void
GenerateRandomBlock(utils::span<std::byte> buffer);
19
20
}
// namespace impl
21
22
/// @brief Generate a block of randomness using a cryptographically secure RNG.
23
///
24
/// Uses a thread-local CryptoPP::AutoSeededRandomPool.
25
void
GenerateRandomBlock
(utils::span<
char
> buffer);
26
27
/// @overload
28
template
<
typename
T>
29
void
GenerateRandomBlock
(utils::span<T> buffer) {
30
static_assert
(std::is_trivially_copyable_v<T>);
31
impl::GenerateRandomBlock(utils::as_writable_bytes(buffer));
32
}
33
34
/// @overload
35
std::string
GenerateRandomBlock
(std::size_t size);
36
37
}
// namespace crypto
38
39
USERVER_NAMESPACE_END
userver
crypto
random.hpp
Generated on Wed May 15 2024 22:31:58 for userver by
Doxygen
1.10.0