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