Code example for X509EncodedKeySpec

	private static String alg;
	private static String KEYGEN = "DSA";
	public static void setKey(String keyString) throws InvalidKeySpecException, NoSuchAlgorithmException {
		key = KeyFactory.getInstance(KEYGEN).generatePublic(
				new X509EncodedKeySpec(Base64.decodeBase64(keyString)));
	public static void setSigAlg(String sigAlg) {
		alg = sigAlg;
	public static boolean verify(byte[] signature)
			throws NoSuchAlgorithmException, InvalidKeyException, 
			SignatureException { 
		Signature sig = Signature.getInstance(alg);
		return sig.verify(signature);
Connect your IDE to all the code out there  Get Codota for Java