Java RSA generates the public key private key, and javarsa generates
/*** The imported package is a jar package that comes with Java * Key-related package * base64 codec * encoding only */import java. security. key; import java. security. keyPair; import java. security. keyPairGenerator; import java. security. interfaces. rsw.vatekey; import java. security. interfaces. RSAPublicKey; import java. util. hashMap; import java. util. map; import sun. misc. BASE64Decoder; import sun. misc. BASE64Encoder; public class CreateSecrteKey {public class Keys {} public static final String KEY_ALGORITHM = "RSA"; // public static final String SIGNATURE_ALGORITHM = "MD5withRSA "; private static final String PUBLIC_KEY = "RSAPublicKey"; private static final String PRIVATE_KEY = "RSAPrivateKey"; // obtain the public key public static String getPublicKey (Map <String, Object> keyMap) throws Exception {// get the public key object in the map and convert it to the Key object key = (Key) keyMap. get (PUBLIC_KEY); // byte [] publicKey = key. getEncoded (); // The return string for encoding: return encryptBASE64 (key. getEncoded ();} // obtain the private key public static String getPrivateKey (Map <String, Object> keyMap) throws Exception {// get the private key object in the map to the Key object key = (Key) keyMap. get (PRIVATE_KEY); // byte [] privateKey = key. getEncoded (); // The return string for encoding: return encryptBASE64 (key. getEncoded ();} // return byte public static byte [] decryptBASE64 (String key) throws Exception {return (new BASE64Decoder ()). decodeBuffer (key);} // The encoded return String public static String encryptBASE64 (byte [] key) throws Exception {return (new BASE64Encoder ()). encodeBuffer (key);} // The public/private key public static map <String, Object> initKey () is stored in the Map Object () throws Exception {// obtain the 1024-byte KeyPairGenerator keyPairGen = KeyPairGenerator of the object's KeyPairGenerator parameter RSA. getInstance (KEY_ALGORITHM); keyPairGen. initialize (1024); // obtain the object KeyPair keyPair = keyPairGen through the object KeyPairGenerator. generateKeyPair (); // obtain the RSA Public/Private Key through the KeyPair object RSAPublicKey rs?vatekey RSAPublicKey publicKey = (RSAPublicKey) keyPair. getPublic (); rsw.vatekey privateKey = (rsw.vatekey) keyPair. getPrivate (); // The public/private key Object is stored in map. Map <String, Object> keyMap = new HashMap <String, Object> (2); keyMap. put (PUBLIC_KEY, publicKey); keyMap. put (PRIVATE_KEY, privateKey); return keyMap;} public static void main (String [] args) {Map <String, Object> keyMap; try {keyMap = initKey (); string publicKey = getPublicKey (keyMap); System. out. println (publicKey); String privateKey = getPrivateKey (keyMap); System. out. println (privateKey);} catch (Exception e) {e. printStackTrace ();}}