public final class RSAPublicKeys extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static RSAPublicKey |
fromPkcs1(String pkcs1PublicKey)
parse public key from pkcs1 format
|
static RSAPublicKey |
fromPkcs8(String pkcs8PublicKey)
parse public key from base64 X509 pkcs8 fromat
|
static RSAPublicKey |
fromPkcs8Pem(String pemPublicKey)
parse public key from pem format
|
static int |
getKeyLength(RSAKey rsaKey)
Gets the rsa key length
|
static RSAPublicKey |
getPublicKey(Certificate cert)
证书中获取公钥
|
static RSAPrivateKey |
inverse(RSAPublicKey publicKey)
对于某些jdk不支持公钥解密及签名,所以要反转公钥为私钥
公钥伪造成私钥来支持解密及签名
|
static String |
toPkcs1(RSAPublicKey publicKey)
MIGJAoGBAKVpbo/Wum3G5ciustuKNGvPX/rgkdZw33QGqBR5UOKUoD5/h/IeQlS7ladX+oa+ciVCXyP854Zq+0RVQ7x87DfAohLmyXlIGOJ7KLJZkUWDYSG0WsPbnTOEmxQcRzqEV5g9pVHIjgPH6N/j6HHKRs5xDEd3pVpoRBZKEncbZ85xAgMBAAE=
ASN1 Encode
The RSA Public key PEM file is specific for RSA keys.
|
static String |
toPkcs8(RSAPublicKey publicKey)
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClaW6P1rptxuXIrrLbijRrz1/64JHWcN90BqgUeVDilKA+f4fyHkJUu5WnV/qGvnIlQl8j/OeGavtEVUO8fOw3wKIS5sl5SBjieyiyWZFFg2EhtFrD250zhJsUHEc6hFeYPaVRyI4Dx+jf4+hxykbOcQxHd6VaaEQWShJ3G2fOcQIDAQAB
DER Encode
convert public key to x509 pkcs8 fromat
|
static String |
toPkcs8Pem(RSAPublicKey publicKey)
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClaW6P1rptxuXIrrLbijRrz1/6
4JHWcN90BqgUeVDilKA+f4fyHkJUu5WnV/qGvnIlQl8j/OeGavtEVUO8fOw3wKIS
5sl5SBjieyiyWZFFg2EhtFrD250zhJsUHEc6hFeYPaVRyI4Dx+jf4+hxykbOcQxH
d6VaaEQWShJ3G2fOcQIDAQAB
-----END PUBLIC KEY-----
new PemObject("RSA PUBLIC KEY", toPkcs8Encode(publicKey))
convert public key to pem fromat (pkcs8)
|
static RSAPublicKey |
toRSAPublicKey(BigInteger modulus,
BigInteger publicExponent)
Build RSAPublicKey with modulus and publicExponent
|
public static RSAPublicKey toRSAPublicKey(BigInteger modulus, BigInteger publicExponent)
modulus - publicExponent - public static RSAPublicKey getPublicKey(Certificate cert)
cert - public static RSAPrivateKey inverse(RSAPublicKey publicKey)
publicKey - public static String toPkcs1(RSAPublicKey publicKey)
ASN1 Encode The RSA Public key PEM file is specific for RSA keys.
convert public key to pkcs1 format
publicKey - public static RSAPublicKey fromPkcs1(String pkcs1PublicKey)
pkcs1PublicKey - encoded base64 pkcs1 public keypublic static String toPkcs8(RSAPublicKey publicKey)
publicKey - public static RSAPublicKey fromPkcs8(String pkcs8PublicKey)
pkcs8PublicKey - encoded base64 x509 pkcs8 fromatpublic static String toPkcs8Pem(RSAPublicKey publicKey)
new PemObject("RSA PUBLIC KEY", toPkcs8Encode(publicKey)) convert public key to pem fromat (pkcs8)
publicKey - public static RSAPublicKey fromPkcs8Pem(String pemPublicKey)
pemPublicKey - encoded pem public keypublic static int getKeyLength(RSAKey rsaKey)
rsaKey - the rsa keyCopyright © 2023. All rights reserved.