Guest User

Untitled

a guest
May 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package rsaMath;
  2.  
  3. /**
  4.  *        :0 <--3
  5.  * cicada  ^    ^penis
  6.  *
  7.  * (d*e)mod φ(n) = 1
  8.  * ^ math
  9.  *
  10.  * @author kzm
  11.  *
  12.  */
  13. public class PrivateKeyBruteForce {
  14.  
  15.     public static void main(String[] args){
  16.        
  17.         //This is example data
  18.         int p = 37;
  19.         int q = 23;
  20.         int n = 851;
  21.         int phi = (p-1)*(q-1);
  22.         int e = 5;
  23.         int d = 0; //This is the private key
  24.  
  25.         boolean key_found = false;
  26.  
  27.         while(!key_found){
  28.             d++;
  29.             if((d*e)%phi == 1){
  30.                 key_found = true;
  31.             }
  32.         }
  33.  
  34.         System.out.println("D = "+d);
  35.  
  36.     }
  37. }
Add Comment
Please, Sign In to add comment