-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrandom.h
42 lines (36 loc) · 1.15 KB
/
random.h
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
35
36
37
38
39
40
41
42
#ifndef RANDOM_H
#define RANDOM_H
#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm> // std::generate
#include <iomanip>
#include <sstream>
#include <iterator>
class Random
{
public:
typedef std::vector<unsigned char>::iterator iterator;
Random();
Random(size_t nBytes);
Random(std::vector<unsigned char>& buffer);
void fillVector(std::vector<unsigned char>::iterator initial, std::vector<unsigned char>::iterator final);
void setRandomBytes();
void setRandomBytes(iterator start, iterator end);
static void randomBuffer(iterator start, iterator end);
static unsigned char getRandomByte();
std::vector<unsigned char> getRandomBytes() const;
void getRandomBytes(std::vector<unsigned char>& buffer) const;
void printHex() const;
static void printHex(const std::vector<unsigned char>& v);
void printInt() const;
static void printInt(const std::vector<unsigned char>& v);
static void print(const std::vector<unsigned char>& v, int mode);
static void setBuffer(std::vector<unsigned char>& v);
private:
size_t nBytes;
std::vector<unsigned char> randomBytes;
enum PrintMode {HEX = 0, INT = 1};
};
class OpenFileException{};
#endif