-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSAEncryption.hh
57 lines (46 loc) · 1.13 KB
/
RSAEncryption.hh
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
#pragma once
#include "BigInteger.hh"
#include "SHA256/SHA256.hh"
#include <string>
#include <iostream>
#include<sstream>
#include <math.h>
#include <assert.h>
#include <bitset>
#include <vector>
#include <new>
#include <fstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <future>
#include <pthread.h>
using namespace std;
class RSAEncryption
{
private:
BigUnsigned myE;
BigUnsigned myN;
BigUnsigned myP;
BigUnsigned myQ;
BigUnsigned myD;
int maxEncryptableCharacters;
static bool isPrime(BigUnsigned SizeInBits);
static BigUnsigned generatePrime(int SizeInBits);
BigUnsigned encryptBytes(BigUnsigned encryptText);
BigUnsigned decryptBytes(BigUnsigned Data);
void createRSAKeys(int bits);
bool AttemptToLoadKeys();
void calculateDAndE();
void WritePrimes();
void writePublicKey();
void writePrivateKey();
void PrintError();
public:
void signFile(string FileLocation);
bool verifyFile(std::string myFileToCheck, std::string mySignature);
void part1OfProject();
//string encryptBytes(string myInputStream);
//string decryptBytes(string myInputStream, string myOutputStream);
RSAEncryption();
~RSAEncryption();
};