-
Notifications
You must be signed in to change notification settings - Fork 1
/
DES.h
47 lines (39 loc) · 1.22 KB
/
DES.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
43
44
45
46
47
#ifndef DES_H
#define DES_H
#include <bitset>
#include <iostream> // std::cout
using std::cout;
using std::cin;
using std::endl;
#include <bitset> // std::bitset
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
#include <string>
using std::string;
#include <iomanip>
using std::setfill;
#include <sstream>
#include "OutputStreamController.h"
class DES {
private:
//fields
bool type;//declares if the object is encryptor or decryptor
std::bitset<48> keys[16];
//functions
int Type(int);
std::bitset<56> ParityDrop(std::bitset<64>);
void Rotate(std::bitset<28>& , unsigned short );
std::bitset<48> KeyCompression( std::bitset<56> );
void KeyGen(std::bitset<64>);
std::bitset<64> Permutate( std::bitset<64> , unsigned short []);
std::bitset<32> Permutate( std::bitset<32> , unsigned short []);
std::bitset<4> S(std::bitset<6>,int);
std::bitset<32> F(std::bitset<32>, std::bitset<48>);
void Rounds(std::bitset<64>&);
public:
OutputStreamController osc;// maybe will be set public
DES(bool);
DES(const DES& );
virtual ~DES();
std::bitset<64> Cipher(std::bitset<64> , std::bitset<64> );
};
#endif /* DES_H */