Generate DSA key pair
import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.SecureRandom; public class MainClass { public static void main(String[] args) throws Exception { KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA"); kpg.initialize(1024, new SecureRandom()); KeyPair dsaKeyPair = kpg.generateKeyPair(); } }