import java.math.BigInteger; public class Q2Tools { Q2Tools() { //Nothing to do here } public void generateRSA() { int e = 65537; //Generate p //Generate q } /** * A^B mod C * @param A * @param B * @param C */ public void fastModularExpon(int A, int B, int C) { String bInBinary = Integer.toBinaryString(B); double test = 1; { int k = 0; //Loop through the Binary String, starting from the right for(int i = bInBinary.length()-1; i >= 0; i--) { if(bInBinary.charAt(i)=='1') { System.out.println("Loop: "+k); double step1 = Math.pow(2, k); System.out.println("STEP1: "+step1); double step2 = Math.pow(A, step1)%C; System.out.println("STEP2: "+step2); test= test*step2; } k++; } } System.out.println(test); System.out.println(Math.pow(5, 64)%19); } }