Java Retrieve the actual value of the public key from the KeyPair object

前端 未结 3 939
梦谈多话
梦谈多话 2020-12-18 15:00

I wanted to ask how to retrieve the actual values of the private and public keys from the KeyPair object because i need to export them and save in a database.



        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 15:27

    You can simply downcast to RSAPrivateKey and RSAPublicKey. Once you've done that you can access the methods of these classes.

    RSAPublicKey pubKey = (RSAPublicKey) keyPair.getPublic());
    BigInteger modulus = pubKey.getModulus();
    

    etc.

提交回复
热议问题