Showing posts with label RSA. Show all posts
Showing posts with label RSA. Show all posts

Friday, 21 June 2013

Rsa In C++

RSA in C++


/* C program for the Implementation Of RSA Algorithm */

#include< stdio.h>
#include< conio.h>

int phi,M,n,e,d,C,FLAG;

int check()
{    int i;
for(i=3;e%i==0 && phi%i==0;i+2) {
FLAG = 1;return;
} FLAG = 0;
} void encrypt() {
     int i;C = 1;
for(i=0;i< e;i++) C=C*M%n; C = C%n; printf("\n\tEncrypted keyword : %d",C);
} void decrypt() {  
     int i;
M = 1; for(i=0;i< d;i++) M=M*C%n; M = M%n; printf("\n\tDecrypted keyword : %d",M);
} void main() {
int p,q,s; clrscr(); printf("Enter Two Relatively Prime Numbers\t: "); scanf("%d%d",&p,&q); n = p*q; phi=(p-1)*(q-1); printf("\n\tF(n)\t= %d",phi); do {
printf("\n\nEnter e\t: ");
scanf("%d",&e); check();
}while(FLAG==1); d = 1; do {
s = (d*e)%phi; d++;
}while(s!=1); d = d-1; printf("\n\tPublic Key\t: {%d,%d}",e,n); printf("\n\tPrivate Key\t: {%d,%d}",d,n); printf("\n\nEnter The Plain Text\t: "); scanf("%d",&M); encrypt(); printf("\n\nEnter the Cipher text\t: "); scanf("%d",&C); decrypt(); getch();
}

Download with Output

Sunday, 16 June 2013

The RSA Algorithm Java code

The RSA algorithm is used for both public key encryption and digital signatures. It is the
most widely used public key encryption algorithm. The basis of the security of the RSA algorithm is that it is mathematically infeasible to factor sufficiently large integers. The RSA algorithm is believed to be secure if its keys have a length of at least 1024-bits.

History
The RSA algorithm was first published in the paper A Method for Obtaining Digital Signatures and Public-Key Cryptosystems in 1977 by Ron Rivest, Adi Shamir and Len Adleman. It is named after the initials of their surnames. The paper was published in the September 1977 issue of The Scientific American. The authors offered to send their full report to anyone who sent them a self-addressed stamped envelope. The NSA did not like the idea of distributing the crytography source code internationally and requested that it be stopped. However the distribution continued when the NSA failed to provide a legal basis for their request. The algorithm was published in The Communications of the ACM the following year.