@Test public void testSaveKeyPair() throws Exception { KeyPair kp = RSAUtil.generateKeyPair(1024); RSAUtil.saveKeyPair(kp, "e:\\RSAKey.txt"); }
public static void saveKeyPair(KeyPair kp, String filePath) throws Exception { File file = new File(filePath); FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(kp); oos.close(); fos.close(); }
RSAUtil { public static void saveKeyPair(KeyPair kp, String filePath) throws Exception { File file = new File(filePath); FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(kp); oos.close(); fos.close(); } }
RSAUtil { public static void saveKeyPair(KeyPair kp, String filePath) throws Exception { File file = new File(filePath); FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(kp); oos.close(); fos.close(); }  }
RSAUtil { public static void saveKeyPair(KeyPair kp, String filePath) throws Exception { File file = new File(filePath); FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(kp); oos.close(); fos.close(); }  static KeyPair generateKeyPair(int keySize); static Map<String, String> createKeys(int keySize); static String getPublicKey(KeyPair keyPair); static String getPrivateKey(KeyPair keyPair); static KeyPair getKeyPair(String filePath); static void saveKeyPair(KeyPair kp, String filePath); static String decryptString(String plaintext, String privateKey); static String encryptString(String plaintext, String publicKey); static RSAPublicKey getPublicKey(String publicKey); static RSAPrivateKey getPrivateKey(String privateKey); static String publicEncrypt(String plaintext, RSAPublicKey publicKey); static String privateDecrypt(String plaintext, RSAPrivateKey privateKey); }
RSAUtil { public static void saveKeyPair(KeyPair kp, String filePath) throws Exception { File file = new File(filePath); FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(kp); oos.close(); fos.close(); }  static KeyPair generateKeyPair(int keySize); static Map<String, String> createKeys(int keySize); static String getPublicKey(KeyPair keyPair); static String getPrivateKey(KeyPair keyPair); static KeyPair getKeyPair(String filePath); static void saveKeyPair(KeyPair kp, String filePath); static String decryptString(String plaintext, String privateKey); static String encryptString(String plaintext, String publicKey); static RSAPublicKey getPublicKey(String publicKey); static RSAPrivateKey getPrivateKey(String privateKey); static String publicEncrypt(String plaintext, RSAPublicKey publicKey); static String privateDecrypt(String plaintext, RSAPrivateKey privateKey); static final String PUBLIC_KEY; static final String PRIVATE_KEY; static final String CHARSET; static final int KEY_SIZE; }