PublicKey.getEncoded(),返回一个包含 SubjectPublicKeyInfo (x.509) 格式的公钥的字节数组,如何将其转换为 RSA 公钥编码?
The PublicKey.getEncoded(), returns a byte array containing the public key in SubjectPublicKeyInfo (x.509) format, how do i convert it to RSA public key encoding?
使用 Bouncy Castle 的 SubjectPublicKeyInfo
,像这样:
Use Bouncy Castle's SubjectPublicKeyInfo
, like this:
byte[] encoded = publicKey.getEncoded();
SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo.getInstance(
ASN1Sequence.getInstance(encoded));
byte[] otherEncoded = subjectPublicKeyInfo.parsePublicKey().getEncoded();
这篇关于将 SubjectPublicKeyInfo 格式的公钥转换为 RSAPublicKey 格式 java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!