Code example for KeyFactory

Methods: generatePublic

0
     * @return RSA专用公钥对象。 
     */ 
    public static RSAPublicKey generateRSAPublicKey(byte[] modulus, byte[] publicExponent) {
        RSAPublicKeySpec publicKeySpec = new RSAPublicKeySpec(new BigInteger(modulus), new BigInteger(publicExponent));
        try { 
            return (RSAPublicKey) keyFactory.generatePublic(publicKeySpec);
        } catch (InvalidKeySpecException ex) {
            LOGGER.error("RSAPublicKeySpec is unavailable.", ex);
        } catch (NullPointerException ex) {
            LOGGER.error("RSAUtils#KEY_FACTORY is null, can not generate KeyFactory instance.", ex);
        } 
        return null; 
    } 
 
    /** 
     * 根据给定的系数和专用指数构造一个RSA专用的私钥对象。 
     *  
     * @param modulus 
     *            系数。 
     * @param privateExponent 
Experience pair programming with AI  Get Codota for Java