blob: 105e390466ab44abc4cb7558e0c941226e5eabfd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#pragma once
#include <string>
#include <cstdint>
class Rng{
public:
virtual uint32_t get()=0;
virtual uint32_t get_uniform(uint32_t upbound)=0;
};
class KeyRng : public Rng{
uint8_t *key;
int keylen;
int idx;
uint64_t state;
void stir();
public:
KeyRng(const char *key,int keylen);
explicit KeyRng(const std::string &key);
KeyRng(const Rng&)=delete; //just keep it at one KeyRng please
~KeyRng();
uint32_t get();
uint32_t get_uniform(uint32_t upbound);
};
class Arc4Rng : public Rng{
public:
uint32_t get();
uint32_t get_uniform(uint32_t upbound);
};
|