本文介绍了将SubjectPublicKeyInfo格式的公钥转换为RSAPublicKey格式java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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的,如下所示:
Use Bouncy Castle's SubjectPublicKeyInfo
, like this:
byte[] encoded = publicKey.getEncoded();
SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(
ASN1Sequence.getInstance(encoded));
byte[] otherEncoded = subjectPublicKeyInfo.parsePublicKey().getEncoded();
这篇关于将SubjectPublicKeyInfo格式的公钥转换为RSAPublicKey格式java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!