23 #include <openssl/rand.h> 33 std::lock_guard<std::mutex> ul(
mutex_);
36 int rc = RAND_bytes(&ret[0], n);
49 for (
size_t i = 0; i < n; ++i)
51 if (idx == bytes.size())
56 if (isalnum(bytes[idx]))
62 assert(ss.str().size() == n);
static std::mutex mutex_
OpenSSL's random number generation is not thread-safe.
static ByteVector GetBytes(size_t n)
Generate n random bytes.
std::vector< uint8_t > ByteVector
static std::string GetASCII(size_t n)
Return a random ASCII string.