Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.security.KeyFactory;

import java.security.NoSuchAlgorithmException;

import java.security.interfaces.DSAPublicKey;

import java.security.spec.InvalidKeySpecException;

import java.security.spec.X509EncodedKeySpec;

public class Main {
    public static DSAPublicKey getDSAPubKeyfromEncoded(byte[] encKey)
            throws NoSuchAlgorithmException, InvalidKeySpecException {
        X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(encKey);
        KeyFactory kf = KeyFactory.getInstance("DSA");
        return (DSAPublicKey) kf.generatePublic(pubKeySpec);
    }
}