aQute.libg.cryptography.SHA1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bnd Show documentation
Show all versions of bnd Show documentation
A command line utility and Ant plugin to wrap, build, or examine bundles.
package aQute.libg.cryptography;
import java.io.*;
import java.security.*;
public class SHA1 extends Digest {
public final static String ALGORITHM = "SHA-1";
public static Digester getDigester(OutputStream... out) throws NoSuchAlgorithmException {
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;
}
};
}
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 - 2024 Weber Informatics LLC | Privacy Policy