RSAPublicKey中有两个方法getModulus()对应公钥的模数;

getPublicExponent()对应公钥的指数;

当但这两个值都是BigInteger类型,需要转成String类型;

引入maven依赖包:

com.nimbusds

nimbus-jose-jwt

8.20

源代码如下:

String pukModule = org.apache.commons.codec.binary.Base64

.encodeBase64URLSafeString(BigIntegerUtils.toBytesUnsigned(publicKey.getModulus()));

String pukPubExp = org.apache.commons.codec.binary.Base64

.encodeBase64URLSafeString(BigIntegerUtils.toBytesUnsigned(publicKey.getPublicExponent()));

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐