Serialize and Deserialize an RSA public key

后端 未结 3 1295
耶瑟儿~
耶瑟儿~ 2021-02-08 13:48
KeyPairGenerator kpg = KeyPairGenerator.getInstance(\"RSA\");
kpg.initialize(1024);
KeyPair kp = kpg.genKeyPair();
Key publicKey = kp.getPublic();
Key privateKey = kp.ge         


        
3条回答
  •  旧时难觅i
    2021-02-08 14:13

    I use the following code to convert a PubliKey to PEM Base64 format

    String publicKeyString = javax.xml.bind.DatatypeConverter.printBase64Binary(publicKey.getEncoded());
    

    I hope it helps.

提交回复
热议问题