public static PublicKey stringToRSAPublicKey (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);
            RSAPublicKeySpec keySpec = new RSAPublicKeySpec(mod, exp);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            return kf.generatePublic(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;
    }
public static PublicKey stringToRSAPublicKey ( 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 ) ; RSAPublicKeySpec keySpec = new RSAPublicKeySpec ( mod , exp ) ; KeyFactory kf = KeyFactory . getInstance ( "RSA" ) ; return kf . generatePublic ( 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 public key from the supplied string.