@@ -0,0 +1,1197 @@
+package org.apollo.tools;%0A%0Aimport java.math.BigInteger;%0Aimport java.security.SecureRandom;%0Aimport java.util.Random;%0A%0A/**%0A * An RSA key generator.%0A *%0A * @author Graham%0A * @author Major%0A */%0Apublic final class RsaKeyGenerator %7B%0A%0A%09/**%0A%09 * The bit count. %3Cstrong%3EStrongly%3C/strong%3E recommended to be at least 2,048.%0A%09 */%0A%09private static final int BIT_COUNT = 2_048;%0A%0A%09/**%0A%09 * The entry point of the RsaKeyGenerator.%0A%09 * %0A%09 * @param args The application arguments.%0A%09 */%0A%09public static void main(String%5B%5D args) %7B%0A%09%09Random random = new SecureRandom();%0A%0A%09%09BigInteger publicKey = BigInteger.valueOf(65535);%0A%09%09BigInteger p, q, phi, modulus, privateKey;%0A%0A%09%09do %7B%0A%09%09%09p = BigInteger.probablePrime(BIT_COUNT / 2, random);%0A%09%09%09q = BigInteger.probablePrime(BIT_COUNT / 2, random);%0A%09%09%09phi = (p.subtract(BigInteger.ONE)).multiply(q.subtract(BigInteger.ONE));%0A%0A%09%09%09modulus = p.multiply(q);%0A%09%09%09privateKey = publicKey.modInverse(phi);%0A%09%09%7D while (modulus.bitLength() != BIT_COUNT %7C%7C privateKey.bitLength() != BIT_COUNT%0A%09%09%09%09%7C%7C !phi.gcd(publicKey).equals(BigInteger.ONE));%0A%0A%09%09System.out.println(%22modulus: %22 + modulus);%0A%09%09System.out.println(%22public key: %22 + publicKey);%0A%09%09System.out.println(%22private key: %22 + privateKey);%0A%09%7D%0A%0A%7D

Add RSA key generator.