mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Add more Rand helper methods
PiperOrigin-RevId: 491409479
This commit is contained in:
committed by
Copybara-Service
parent
2012acdbcc
commit
0cb5b004e4
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <openssl/rand.h>
|
||||
|
||||
namespace crypto {
|
||||
@@ -28,4 +30,11 @@ void RandBytes(absl::Span<uint8_t> bytes) {
|
||||
RandBytes(bytes.data(), bytes.size());
|
||||
}
|
||||
|
||||
std::string RandBytes(size_t length) {
|
||||
std::string result(length, 0);
|
||||
RandBytes(const_cast<std::string::value_type *>(result.data()),
|
||||
result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace crypto
|
||||
|
||||
Reference in New Issue
Block a user