List of usage examples for java.security.spec DSAPrivateKeySpec getX
public BigInteger getX()
From source file:MainClass.java
public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeySpecException { KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA"); kpg.initialize(512);// w ww .j av a2s .c om KeyPair keys = kpg.genKeyPair(); PrivateKey priKey = keys.getPrivate(); PublicKey pubKey = keys.getPublic(); KeyFactory kf = KeyFactory.getInstance("DSA"); DSAPrivateKeySpec dsaPriKeySpec = (DSAPrivateKeySpec) kf.getKeySpec(priKey, DSAPrivateKeySpec.class); DSAPublicKeySpec dsaPubKeySpec = (DSAPublicKeySpec) kf.getKeySpec(pubKey, DSAPublicKeySpec.class); System.out.println("\nDSA Private Key"); System.out.println("\nx = " + dsaPriKeySpec.getX()); System.out.println("\nDSA Public Key"); System.out.println("\ng = " + dsaPubKeySpec.getG()); System.out.println("\np = " + dsaPubKeySpec.getP()); System.out.println("\nq = " + dsaPubKeySpec.getQ()); System.out.println("\ny = " + dsaPubKeySpec.getY()); }