SPSP
Simple publish-subscribe protocol. Connects low power IoT clients to MQTT.
All Classes Files Functions Variables Typedefs Enumerations
testing/spsp/random.hpp
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <cstdint>
13 #include <cstdlib>
14 
15 #include "spsp/random_if.hpp"
16 
17 namespace SPSP
18 {
23  class Random : public IRandom
24  {
25  public:
26  inline void bytes(void* buf, size_t len) const noexcept
27  {
28  uint8_t* buf8 = static_cast<uint8_t*>(buf);
29 
30  for (size_t i = 0; i < len; i++) {
31  buf8[i] = rand();
32  }
33  }
34  };
35 } // namespace SPSP
random_if.hpp
Platform-dependent random generator interface.
SPSP::Random::bytes
void bytes(void *buf, size_t len) const noexcept
Generates len truly random bytes in buf
Definition: testing/spsp/random.hpp:26