-
Notifications
You must be signed in to change notification settings - Fork 0
/
hill-algorithm.h
63 lines (52 loc) · 1.29 KB
/
hill-algorithm.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
57
58
59
60
61
62
63
//*********************************************************
// hill-algorithm.h
//
// Class and prototypes
//
// Author: Jeff Wen
// Email: [email protected]
//*********************************************************
#ifndef HILL_ALGORITHM_H
#define HILL_ALGORITHM_H
#include <array>
const int matrSize = 4;
#ifdef DEBUG
# define DEBUG_PRINT(m) std::cout << (m)
#else
# define DEBUG_COUT(m)
#endif
class Matrix
{
public:
Matrix(){}
Matrix(std::array<std::array<int, matrSize>, matrSize>);
Matrix(const Matrix&);
// Overload operator "[]"
const std::array<int, matrSize> operator[](const unsigned) const;
std::array<int, matrSize>& operator[](const unsigned);
// Overload operator "+"
Matrix operator+(const Matrix& b);
// Left multi b
Matrix leftMulti(Matrix b);
// Print the matrix
void print(void);
// Convert to string, read in row
std::string toString(void);
// Parse string
int parseString(std::string);
// Calc cofactor matrix
Matrix cofactor(void);
// Calc transpose matrix
Matrix transpose(void);
// Inverse the matrix
Matrix inverse(int);
// Calculate the determinant
int det();
// Cipher
Matrix hillCipher(Matrix);
// Decryption
Matrix hillDecrypt(Matrix);
protected:
std::array<std::array<int, matrSize>, matrSize> matrix;
};
#endif