-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencryption.cpp
More file actions
51 lines (44 loc) · 903 Bytes
/
Copy pathencryption.cpp
File metadata and controls
51 lines (44 loc) · 903 Bytes
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
#include"encryption.h"
double encryption::RSA_Encryption(double original_mess , double n , double e)
{
Encreipted_Mess =pow(original_mess,e);
Encreipted_Mess= fmod(Encreipted_Mess,n);
return Encreipted_Mess;
}
double Euler::RSA_Calc_Euler(double p, double q)
{
int euler1 = (p-1)*(q-1);
return euler1;
}
int n::RSA_Calc_N(double p, double q)
{
double n1 = p * q;
return n1;
}
int gcd(int a, int b)
{
int t;
while(1) {
t= a%b;
if(t==0)
return b;
a = b;
b= t;
}
}
double e::RSA_Generate_e(double euler)
{
//public key
//e stands for encrypt
double temp;
e=2;
//for checking that 1 < e < phi(n) and gcd(e, phi(n)) = 1; i.e., e and phi(n) are coprime.
while(e<euler) {
temp = gcd(e,euler);
if(temp==1)
break;
else
e++;
}
return e;
}