1
0
qswiki/random.h

29 Zeilen
511 B
C

2018-11-03 17:12:20 +01:00
#ifndef RANDOM_H
#define RANDOM_H
#include <unistd.h>
#include <sys/syscall.h>
#ifdef __linux__
#include <sys/random.h>
2018-11-03 17:12:20 +01:00
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#if __OpenBSD__
inline int getrandom(void *buf, size_t buflen, unsigned int flags)
{
arc4random_buf(buf, buflen);
return 0;
}
#endif
/* TODO: if the >=C++11 prngr are good enough, use them */
class Random
{
public:
Random();
std::string getRandomHexString(unsigned int bytes);
};
#endif // RANDOM_H