import java.security.*; import java.io.*; public class Votmetelooja{ public static void main(String argumendid[]) throws Exception{ String avavotmefail="avavoti.key"; String salavotmefail="salavoti.key"; KeyPairGenerator votmepaarilooja=KeyPairGenerator.getInstance("DSA"); votmepaarilooja.initialize(512); //jagamisja"a"k KeyPair votmepaar=votmepaarilooja.generateKeyPair(); FileOutputStream valja1=new FileOutputStream(avavotmefail); valja1.write(votmepaar.getPublic().getEncoded()); valja1.close(); FileOutputStream valja2=new FileOutputStream(salavotmefail); valja2.write(votmepaar.getPrivate().getEncoded()); valja2.close(); } }