当我使用java库生成公钥时,它显示为
Sun RSA public key, 1024 bits
modulus: 90455558766847231187855444386104902055754158435274375899360135171624950510999..
public exponent: 65537
当我使用http://travistidwell.com/blog/2013/09/06/an-online-rsa-public-and-private-key-generator/等任何在线门户生成时 它显示像
-----BEGIN PUBLIC KEY-----
MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgE3xIde7MizPdmyJ3GgDmPcLsfAY
.............
-----END PUBLIC KEY-----
其实问题是: 如果我使用默认的java库验证公钥
PublicKey key = KeyFactory.getInstance("RSA")
.generatePublic(new X509EncodedKeySpec(pub));
我收到无效的密钥错误。
如果有人知道,如何使用JSCH库验证这些密钥或使用java默认库验证门户生成的公钥。
答案 0 :(得分:0)
我不确定我理解你的问题。
但也许,您正在寻找KeyPair.writeSECSHPublicKey
:
/**
* Writes the public key with the specified comment to the output stream in
* the format defined in https://www.ietf.org/rfc/rfc4716.txt
* @param out output stream
* @param comment comment
*/
public void writeSECSHPublicKey(java.io.OutputStream out, String comment)
/**
* Writes the public key with the specified comment to the output stream in
* the format defined in https://www.ietf.org/rfc/rfc4716.txt
* @param name file name
* @param comment comment
* @see #writeSECSHPublicKey(java.io.OutputStream out, String comment)
*/
public void writeSECSHPublicKey(String name, String comment)