Java
From Wiki
import java.math.*;
import java.security.*;
class R{BigInteger n,d,o=BigInteger.ONE,t=o.add(o),e=t.add(o);R(int b)
{BigInteger p=new BigInteger(b,99,new SecureRandom()),q=new BigInteger
(b,99,new SecureRandom()),m=p.subtract(o).multiply(q.subtract(o));for(
;m.gcd(e).intValue()>1;e=e.add(t));d=e.modInverse(m);n=p.multiply(q);}
BigInteger a(BigInteger m) {return m.modPow(e, n); } //modified code;
BigInteger b(BigInteger m){return m.modPow(d,n);}}//originally: Paul J
