Generate Test Keys

This commit is contained in:
mrbesen 2017-05-21 16:24:03 +02:00
parent d95f4dd71a
commit 5c6600e9f6
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
package de.mrbesen;
import java.util.Random;
public class GenTestEncryption {
public static void main(String[] args) {
long max = 50000;
long a, b, c, d, M, v, e, n;
Random rand = new Random();
a = rand.nextLong() % max;
b = rand.nextLong() % max;
c = rand.nextLong() % max;
d = rand.nextLong() % max;
//positive only
a = (a > 0 ? a : -a);
b = (b > 0 ? b : -b);
c = (c > 0 ? c : -c);
d = (d > 0 ? d : -d);
M = (a*b)-1;
v = (c*M) +a;
e = (d*M) +b;
n = (v*e)-1 / M;
System.out.println("e: " + e + "\nv: " + v + "\nn: " + n);
if((v*e) % n == 1) {
System.out.println("Schlüßel gültig!");
}
}
}