blob: 5b25cf3883caa42d72c6238d6a7a857a9797b7ad [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +00001package aQute.libg.cryptography;
2
3import java.io.*;
4import java.security.*;
5
6
7
8public class SHA256 extends Digest {
9 public final static String ALGORITHM = "SHA256";
10
11
12 public static Digester<SHA256> getDigester(OutputStream ... out ) throws NoSuchAlgorithmException {
13 MessageDigest md = MessageDigest.getInstance(ALGORITHM);
14 return new Digester<SHA256>(md, out) {
15 @Override public SHA256 digest() throws Exception {
16 return new SHA256(md.digest());
17 }
18
19 @Override public SHA256 digest(byte[] bytes) {
20 return new SHA256(bytes);
21 }
22 @Override public String getAlgorithm() {
23 return ALGORITHM;
24 }
25 };
26 }
27
28 public SHA256(byte[] b) {
29 super(b, 32);
30 }
31
32
33 @Override public String getAlgorithm() { return ALGORITHM; }
34
35}