MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Signature;
import java.security.SignedObject;
import java.util.Vector;

public class MainClass {
    public static void main(String[] args) throws Exception {
        String alg = "DSA";
        KeyPairGenerator kg = KeyPairGenerator.getInstance(alg);
        KeyPair keyPair = kg.genKeyPair();

        Vector v = new Vector();
        v.add("This is a test!");
        Signature sign = Signature.getInstance(alg);
        SignedObject so = new SignedObject(v, keyPair.getPrivate(), sign);
        System.out.println(so.verify(keyPair.getPublic(), sign));
    }
}