Code example for RSAPrivateKeySpec

0
            BigInteger e = bar.readBigInteger();
            BigInteger n = bar.readBigInteger();
 
            // Read the private key 
            BigInteger p = bar.readBigInteger();
            RSAPrivateKeySpec prvSpec = new RSAPrivateKeySpec(n, p);
            RSAPublicKeySpec pubSpec = new RSAPublicKeySpec(n, e);
            KeyFactory kf = KeyFactory.getInstance("RSA");
            prvKey = (RSAPrivateKey) kf.generatePrivate(prvSpec);
            pubKey = (RSAPublicKey) kf.generatePublic(pubSpec);
        } catch (Exception e) {
            throw new InvalidKeyException();
        } 
    } 
 
    /** 
     * 
     * 
     * @param obj 
     * 
Contextual code suggestions in your IDE  Get Codota for Java