public static RSAPublicKey getRSAPublidKeyBybase64(String base64s) {
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(CodeUtils.base64Decode(base64s));
RSAPublicKey publicKey = null;
     KeyFactory keyFactory = KeyFactory.getInstance("RSA");
try {
publicKey = (RSAPublicKey)keyFactory.generatePublic(keySpec);
} catch (InvalidKeySpecException var4) {
LOGGER.error("base64编码=" + base64s + "转RSA公钥失败", var4);
} return publicKey;
} public static RSAPrivateKey getRSAPrivateKeyBybase64(String base64s) {
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(CodeUtils.base64Decode(base64s));
RSAPrivateKey privateKey = null;
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
try {
privateKey = (RSAPrivateKey)keyFactory.generatePrivate(keySpec);
} catch (InvalidKeySpecException var4) {
LOGGER.error("base64编码=" + base64s + "转RSA私钥失败", var4);
} return privateKey;
}
04-27 21:05