Hi all,
i am creating this RSA(Rivest, Shamir, Adleman)security programm for encrypting and decrypting data.It follows the following algorithm:
�A public modulus n and public key e where
on is a product of two secret primes p and q, where n=pq
oe is chosen relatively prime to f(n) = (p-1)(q-1)
�A Private key, d where d = e-1 mod (p-1)(q-1)
Encryption: c = me mod n
Decryption: m = cd mod n
It is a must to keep p, q, and d secret.
The program is supposed to give an encrypted format of a given input.
So far i have come up with the following and i am at a deadlock seeing that i am new in java.Please help....
RSATest.java
import java.io.*;
import java.security.*;
import java.math.BigInteger;
public class RSATest {
public static void main(
String[] args) throws IOException {
BigInteger n,d,e,m,c,m1;
// rsa pub (e) and private (d) keys mod n
n = new BigInteger( "124678993171231689969384781953680079775230295513890833332205993261431214145017901246238895519988180024789662211326063630595211864218422061007297168871256015754795337062552934380314452356719663911970941588688494143925816839053715303078961517266498182523620484138056115643133052630577199833387088308265430407691");
e = BigInteger.valueOf(37L);
d = new BigInteger( "15163661331636286617898149156528658351041522427365101351214242423687580098718393394812838644322886759771715674350467198315633875377916196608995601619477080259016270150094279303456010961499711962504117011699439969646810687936076796727618344280066728733690010290995392440062128773122006698090773675868324510565");
m = new BigInteger(1024, new SecureRandom());
m = m.mod(n);
c = m.modPow(e,n);
m1 = c.modPow(d,n);
System.out.println("msg m " + m.toString());
System.out.println("msg m1 " + m1.toString());
}
}