All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aQute.libg.cryptography.SHA1 Maven / Gradle / Ivy

Go to download

A main program (executable JAR) that will listen to port 29998. At first, it can only answer that it is an Envoy (a limited agent). The only function it supports is installing a -runpath. It will then create a framework + agent and transfer the connection to the just installed agent who will then install the bundles. This JAR is a main command for JPM called bndremote. In JPM, it will start up with debug enabled. This JAR does some highly complicated class loading wizardy to ensure that it does not enforce any constraints on the -runpath.

The newest version!
package aQute.libg.cryptography;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import aQute.bnd.exceptions.Exceptions;

public class SHA1 extends Digest {
	public final static String ALGORITHM = "SHA-1";

	public static Digester getDigester(OutputStream... out) {
		try {
			MessageDigest md = MessageDigest.getInstance(ALGORITHM);
			return new Digester(md, out) {
				@Override
				public SHA1 digest() throws Exception {
					return new SHA1(md.digest());
				}

				@Override
				public SHA1 digest(byte[] bytes) {
					return new SHA1(bytes);
				}

				@Override
				public String getAlgorithm() {
					return ALGORITHM;
				}
			};
		} catch (NoSuchAlgorithmException e) {
			throw Exceptions.duck(e);
		}
	}

	public SHA1(byte[] b) {
		super(b, 20);
	}

	@Override
	public String getAlgorithm() {
		return ALGORITHM;
	}

	public static SHA1 digest(byte[] data) throws Exception {
		return getDigester().from(data);
	}

	public static SHA1 digest(File f) throws NoSuchAlgorithmException, Exception {
		return getDigester().from(f);
	}

	public static SHA1 digest(InputStream f) throws NoSuchAlgorithmException, Exception {
		return getDigester().from(f);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy