package rsa;
import java
public class RSA {
private long p
public RSA(){
int pIndex = (int)(Math
int qIndex;
int eIndex;
do{
qIndex = (int)(Math
}
while(qIndex==pIndex);
do{
eIndex = (int)(Math
}
while(eIndex==pIndex||eIndex==pIndex);
p =
q =
e =
n = p*q;
d = calculateD();
}
private long calculateD(){
long t
long r
do{
long q = r
r
if(r
t
while(t
t
}
if(t
t
}
r
r
t
t
}while(r
if(r
return
}
else{
return t
}
}
public long getE() {
return e;
}
public long getN() {
return n;
}
public long getD() {
return d;
}
public BigInteger encode(BigInteger data){
return pow(data
}
public BigInteger decode(BigInteger code){
return pow(code
}
public BigInteger pow(BigInteger data
data = data
return data;
}
public static void main(String args[]){
RSA rsa = new RSA();
BigInteger data = new BigInteger(
long oldtime = System
BigInteger code = rsa
long newtime = System
double codetime = ((double)(newtime
oldtime = System
BigInteger decode = rsa
newtime = System
double decodetime = ((double)(newtime
System
System
System
System
System
System
}
}
From:http://tw.wingwit.com/Article/program/Java/Javascript/201311/25327.html