-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcipherengine.h
56 lines (47 loc) · 1.59 KB
/
cipherengine.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
48
49
50
51
52
53
54
55
56
/*
* Author: Justin Muskopf
* Instructor: Mark Hoffman
* Course: CSCE 4550, Fall 2018
* Assignment: Project 2
*/
#ifndef CIPHERENGINE_H
#define CIPHERENGINE_H
#include <stdint.h>
#include <string>
#include <vector>
#include "file.h"
class CipherEngine
{
public:
void setOutputFile(File &file);
void encrypt(std::string _plaintext, std::string _key);
private:
static const int UPPER_MOD = 65;
static const int NUM_ROWS = 4;
static const int NUM_COLS = 4;
std::string plaintext; // The plaintext
std::string key; // The key
std::string ciphered; // Ciphered text
std::string padded; // Padded text
std::string shifted; // Shifted text
std::string parityChars; // The parity string
std::string mixedColumns;// Mixed columns string
File outFile; // Output file
int numPaddedLines; // Number of padded lines
// Define CipherBlock types
typedef unsigned char CipherBlock[NUM_COLS][NUM_ROWS];
typedef unsigned char CipherRow[NUM_COLS];
typedef unsigned char CipherColumn[NUM_ROWS];
// The vector of parity numbers
std::vector<int> parityNumbers;
void printAndWriteLine(std::string line);
void removeWhiteSpaceFromPlainText();
void applyCipher();
void padCipheredText();
void shiftPaddedText();
void calculateParity();
void mixColumns(CipherColumn &col);
void mixColumnsOfCipherBlock(CipherBlock block);
int rgfMul(int mul);
};
#endif