BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
rand.cpp
Go to the documentation of this file.
1 #include <openssl/rand.h>
2 #include <fc/crypto/openssl.hpp>
4 #include <fc/fwd_impl.hpp>
5 
6 
7 namespace fc {
8 
9 void rand_bytes(char* buf, int count)
10 {
11  static int init = init_openssl();
12  (void)init;
13 
14  int result = RAND_bytes((unsigned char*)buf, count);
15  if (result != 1)
16  FC_THROW("Error calling OpenSSL's RAND_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
17 }
18 
19 } // namespace fc
void rand_bytes(char *buf, int count)
Definition: rand.cpp:9
int init_openssl()
Definition: openssl.cpp:61
#define FC_THROW(...)
Definition: exception.hpp:366
Defines exception&#39;s used by fc.
Definition: api.hpp:15