
public class Gen {
	
}

@@ -1,24 +1,1608 @@
 %0A
-public class Gen %7B%0A%09
+import java.security.KeyPair;%0Aimport java.security.KeyPairGenerator;%0Aimport java.security.NoSuchAlgorithmException;%0Aimport java.security.PrivateKey;%0Aimport java.security.Provider;%0Aimport java.security.PublicKey;%0Aimport java.security.Security;%0Aimport java.security.spec.X509EncodedKeySpec;%0A%0Aimport javax.crypto.KeyGenerator;%0A%0Aimport org.bouncycastle.jce.provider.BouncyCastleProvider;%0A%0Apublic class Gen %7B%0A%09private static final String DIGITS = %220123456789abcdef%22;%0A%09%0A    public static void main(String%5B%5D args) %7B%0A%09%09Security.addProvider(new BouncyCastleProvider());%0A%09%09Provider bc = Security.getProvider(%22BC%22);%0A%09%09%0A%09%09String algorithm = %22RSA%22;%0A%09%09int keysize = 1024;%0A%09%09KeyPairGenerator kg = null;%0A%09%09try %7B%0A%09%09%09kg = KeyPairGenerator.getInstance(algorithm, bc);%0A%09%09%09kg.initialize(keysize);%0A%09%09%7D catch (NoSuchAlgorithmException e) %7B%0A%09%09%09System.out.println(%22Can't find algorithm %22 + algorithm);%0A%09%09%09System.exit(-1);%0A%09%09%7D%0A%09%09%0A%09%09KeyPair keyPair = kg.generateKeyPair();%0A%09%09PrivateKey privateKey = keyPair.getPrivate();%0A%09%09PublicKey publicKey = keyPair.getPublic();%0A%0A%09%09System.out.println(toHex(publicKey.getEncoded()));%0A%09%09System.out.println(toHex(privateKey.getEncoded()));%0A%09%7D%0A    %0A%09public static String toHex(byte%5B%5D data) %7B%0A%09%09return toHex(data, data.length);%0A%09%7D%0A%09%0A%09public static String toHex(byte%5B%5D data, int length)%0A    %7B%0A        StringBuffer%09buf = new StringBuffer();%0A        %0A        for (int i = 0; i != length; i++)%0A        %7B%0A            int%09v = data%5Bi%5D & 0xff;%0A            %0A            buf.append(DIGITS.charAt(v %3E%3E 4));%0A            buf.append(DIGITS.charAt(v & 0xf));%0A        %7D%0A        %0A        return buf.toString();%0A    %7D
 %0A%7D%0A

Implement Gen class Generate a public/private key pair with RSA.