public boolean validateSignatureFromByteArray(final byte[] sig,
			final byte[] data, PublicKey pKey) throws NoSuchAlgorithmException {

		byte[] newd;
		byte[] ver;

		MessageDigest messageDigest = MessageDigest.getInstance("MD5");
		try {
			cipher.init(Cipher.DECRYPT_MODE, pKey);
			newd = cipher.doFinal(sig);
		} catch (Exception e) {
			return false;
		}

		messageDigest.update(data);
		ver = messageDigest.digest();

		// make sure they match
		if (newd.length > ver.length) {
			return false;
		}
		for (int i = 0; i < newd.length; ++i) {
			if (ver[i] != newd[i]) {
				return false;
			}
		}

		return true;
	}