comparison app/src/main/java/ch/ethz/ssh2/crypto/digest/SHA256.java @ 438:d29cce60f393

migrate from Eclipse to Android Studio
author Carl Byington <carl@five-ten-sg.com>
date Thu, 03 Dec 2015 11:23:55 -0800
parents src/ch/ethz/ssh2/crypto/digest/SHA256.java@071eccdff8ea
children
comparison
equal deleted inserted replaced
437:208b31032318 438:d29cce60f393
1 /*
2 * Copyright (c) 2006-2011 Christian Plattner. All rights reserved.
3 * Please refer to the LICENSE.txt for licensing details.
4 */
5 package ch.ethz.ssh2.crypto.digest;
6
7 import java.security.DigestException;
8 import java.security.MessageDigest;
9 import java.security.NoSuchAlgorithmException;
10
11 /**
12 * @version $Id: SHA256.java 152 2014-04-28 11:02:23Z dkocher@sudo.ch $
13 */
14 public final class SHA256 implements Digest {
15
16 private MessageDigest md;
17
18 public SHA256() {
19 try {
20 md = MessageDigest.getInstance("SHA-256");
21 }
22 catch (NoSuchAlgorithmException e) {
23 throw new IllegalArgumentException(e);
24 }
25 }
26
27 public final int getDigestLength() {
28 return md.getDigestLength();
29 }
30
31 public final void reset() {
32 md.reset();
33 }
34
35 public final void update(byte b[]) {
36 this.update(b, 0, b.length);
37 }
38
39 public final void update(byte b[], int off, int len) {
40 md.update(b, off, len);
41 }
42
43 public final void update(byte b) {
44 md.update(b);
45 }
46
47 public final void digest(byte[] out) throws DigestException {
48 this.digest(out, 0);
49 }
50
51 public final void digest(byte[] out, int off) throws DigestException {
52 md.digest(out, off, out.length);
53 }
54 }