Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
RSA Algo
#include <iostream> #include <algorithm> #include <math.h> using namespace std ; int main() { int p,q,m,n,phi,e,d; int f=2; cout<<"Enter Message:"; cin>>m; cout<<"Enter P:"; cin>>p; cout<<"Enter Q:"; cin>>q; n=p*q; phi = (p-1)*(q-1); for(int i=2;i<phi;i++){ if(__gcd(i,phi)==1){ e=i; break; } } while(1){ if((phi*f+1)%e==0){ d = (phi*f+1)/e; break; } f++; } double C = pow(m,e); C = fmod(C,n); double D = pow(C,d); D = fmod(D,n); cout<<"e is:"<<e<<endl; cout<<"d is:"<<d<<endl; cout<<"C is:"<<C<<endl; cout<<"D is:"<<D; return 0; }
run
|
edit
|
history
|
help
0
Assignment 2
Ahora si?
14th Dec Project1 v0.5
lol
Project 5 v0.11
A_141205_CadenaValorNumerico
Atoi without minus
demo_strlen
Iterated sums
Adding sums of two 1-D arrays