Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;

public class Main {
    public static void main(String[] argv) throws Exception {
        // Generate a 1024-bit Digital Signature Algorithm (DSA) key pair
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
        keyGen.initialize(1024);
        KeyPair keypair = keyGen.genKeyPair();
        PrivateKey privateKey = keypair.getPrivate();
        System.out.println(privateKey);
        PublicKey publicKey = keypair.getPublic();
        System.out.println(publicKey);
    }
}