-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntitateRSA.h
74 lines (52 loc) · 1.74 KB
/
EntitateRSA.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
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include <string>
using std::string;
using std::to_string;
#include <unordered_set>
using std::unordered_set;
#include <random>
using std::random_device;
using std::mt19937;
#include <iostream>
using std::cout;
using std::cin;
using std::ostream;
#include <cmath>
using std::fmod;
using std::pow;
#include <stdexcept>
using std::logic_error;
// ReSharper disable once CppInconsistentNaming
class EntitateRSA
{
static const string NEDEFINIT;
static const size_t LIMITA_INFERIOARA_NUMAR_ALEATOR;
static const size_t LIMITA_SUPERIOARA_NUMAR_ALEATOR;
static random_device _generator_seed; // https://www.cplusplus.com/reference/random/random_device/
static mt19937 _generator_numere_aleatorii; // https://www.cplusplus.com/reference/random/mt19937/
size_t _cheie_privata;
size_t _cheie_publica;
unsigned long long _produs_numere_prime;
string _nume;
enum TipCheie
{
Privata,
Publica
};
static size_t GetCelMaiMareDivizorComun(const size_t&, const size_t&);
static size_t GenerareNumarRandom();
static bool EstePrim(const size_t&);
static size_t GenerareNumarPrimRandom();
size_t GenerareCheiePrivata(const unsigned long long&);
size_t GenerareCheiePublica(const unsigned long long&) const;
size_t GetCheieFolosita(const TipCheie&) const;
unsigned long long EncriptareDecriptare(const unsigned long long&, const TipCheie&) const;
public:
EntitateRSA();
explicit EntitateRSA(const string&);
~EntitateRSA();
void GenerareChei();
size_t EncriptareDecriptarePrivata(const size_t&) const;
size_t EncriptareDecriptarePublica(const size_t&) const;
friend ostream& operator<<(ostream& p_stream, const EntitateRSA& p_entitate);
};