FileDocCategorySizeDatePackage
Export.javaAPI DocExample2177Sun Oct 25 18:13:36 GMT 1998None

Export

public class Export extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		try {
			KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA");
			kpg.initialize(512, new SecureRandom());
			KeyPair kp = kpg.generateKeyPair();
			Class spec = Class.forName("java.security.spec.DSAPrivateKeySpec");
			KeyFactory kf = KeyFactory.getInstance("DSA");
			DSAPrivateKeySpec ks = (DSAPrivateKeySpec) kf.getKeySpec(kp.getPrivate(), spec);
			FileOutputStream fos = new FileOutputStream("exportedKey");
			ObjectOutputStream oos = new ObjectOutputStream(fos);
			System.out.println("provider " + kf.getProvider());
			oos.writeObject(ks.getX());
			oos.writeObject(ks.getP());
			oos.writeObject(ks.getQ());
			oos.writeObject(ks.getG());
		} catch (Exception e) {
			e.printStackTrace();
		}