public static PrivateKey stringToRSAPrivateKey ( String str ) { try { BigInteger mod = new BigInteger ( str . substring ( 0 , str . indexOf ( SPLIT ) ) , 16 ) ; BigInteger exp = new BigInteger ( str . substring ( str . indexOf ( SPLIT ) + 1 ) , 16 ) ; RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec ( mod , exp ) ; KeyFactory kf = KeyFactory . getInstance ( "RSA" ) ; return kf . generatePrivate ( keySpec ) ; } catch ( NumberFormatException nfe ) { log . warning ( "Failed to read key from string." , "str" , str , nfe ) ; } catch ( GeneralSecurityException gse ) { log . warning ( "Failed to read key from string." , "str" , str , gse ) ; } return null ; }
Creates a private key from the supplied string .