src/main/java/com/webank/wecross/account/service/utils/RSAUtility.java
/**
     * @param content
     * @return
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     */
@param content
@return
@throws NoSuchAlgorithmException
@throws InvalidKeySpecException
@param content @return @throws NoSuchAlgorithmException @throws InvalidKeySpecException
public static PrivateKey createPrivateKey(String content)
            throws NoSuchAlgorithmException, InvalidKeySpecException, IOException {
        PemReader pemReader = new PemReader(new StringReader(content));
        PemObject pemObject = pemReader.readPemObject();
        byte[] pemContent = pemObject.getContent();
        RSAPrivateKey rsaPrivateKey =
                RSAPrivateKey.getInstance((ASN1Sequence) ASN1Sequence.fromByteArray(pemContent));
        RSAPrivateKeySpec rsaPrivateKeySpec =
                new RSAPrivateKeySpec(
                        rsaPrivateKey.getModulus(), rsaPrivateKey.getPrivateExponent());
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        PrivateKey privateKey = keyFactory.generatePrivate(rsaPrivateKeySpec);
        return privateKey;
    }
public static PrivateKey createPrivateKey ( String content ) throws NoSuchAlgorithmException , InvalidKeySpecException , IOException { PemReader pemReader = new PemReader ( new StringReader ( content ) ) ; PemObject pemObject = pemReader . readPemObject ( ) ; byte [ ] pemContent = pemObject . getContent ( ) ; RSAPrivateKey rsaPrivateKey = RSAPrivateKey . getInstance ( ( ASN1Sequence ) ASN1Sequence . fromByteArray ( pemContent ) ) ; RSAPrivateKeySpec rsaPrivateKeySpec = new RSAPrivateKeySpec ( rsaPrivateKey . getModulus ( ) , rsaPrivateKey . getPrivateExponent ( ) ) ; KeyFactory keyFactory = KeyFactory . getInstance ( "RSA" ) ; PrivateKey privateKey = keyFactory . generatePrivate ( rsaPrivateKeySpec ) ; return privateKey ; }
@param content
 @return
 @throws NoSuchAlgorithmException
 @throws InvalidKeySpecException
@param content @return @throws NoSuchAlgorithmException @throws InvalidKeySpecException