PublicKey.getEncoded(),返回一个包含SubjectPublicKeyInfo(x.509)格式的公共(public) key 的字节数组,如何将其转换为RSA公共(public) key 编码?
最佳答案
使用Bouncy CaSTLe的 SubjectPublicKeyInfo
,如下所示:
byte[] encoded = publicKey.getEncoded();
SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(
ASN1Sequence.getInstance(encoded));
byte[] otherEncoded = subjectPublicKeyInfo.parsePublicKey().getEncoded();