Mercurial > 510Connectbot
comparison src/ch/ethz/ssh2/crypto/digest/HashForSSH2Types.java @ 307:071eccdff8ea ganymed
fix java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 30 Jul 2014 14:16:58 -0700 |
parents | 91a31873c42a |
children |
comparison
equal
deleted
inserted
replaced
305:d2b303406d63 | 307:071eccdff8ea |
---|---|
20 public HashForSSH2Types(Digest md) { | 20 public HashForSSH2Types(Digest md) { |
21 this.md = md; | 21 this.md = md; |
22 } | 22 } |
23 | 23 |
24 public HashForSSH2Types(String type) { | 24 public HashForSSH2Types(String type) { |
25 if(type.equals("SHA1")) { | 25 if (type.equals("SHA1")) { |
26 md = new SHA1(); | 26 md = new SHA1(); |
27 } | 27 } |
28 else if(type.equals("SHA2")) { | 28 else if (type.equals("SHA2")) { |
29 md = new SHA256(); | 29 md = new SHA256(); |
30 } | 30 } |
31 else if(type.equals("MD5")) { | 31 else if (type.equals("MD5")) { |
32 md = new MD5(); | 32 md = new MD5(); |
33 } | 33 } |
34 else { | 34 else { |
35 throw new IllegalArgumentException(String.format("Unknown algorithm %s", type)); | 35 throw new IllegalArgumentException(String.format("Unknown algorithm %s", type)); |
36 } | 36 } |
43 public void updateBytes(byte[] b) { | 43 public void updateBytes(byte[] b) { |
44 md.update(b); | 44 md.update(b); |
45 } | 45 } |
46 | 46 |
47 public void updateUINT32(int v) { | 47 public void updateUINT32(int v) { |
48 md.update((byte) (v >> 24)); | 48 md.update((byte)(v >> 24)); |
49 md.update((byte) (v >> 16)); | 49 md.update((byte)(v >> 16)); |
50 md.update((byte) (v >> 8)); | 50 md.update((byte)(v >> 8)); |
51 md.update((byte) (v)); | 51 md.update((byte)(v)); |
52 } | 52 } |
53 | 53 |
54 public void updateByteString(byte[] b) { | 54 public void updateByteString(byte[] b) { |
55 updateUINT32(b.length); | 55 updateUINT32(b.length); |
56 updateBytes(b); | 56 updateBytes(b); |
76 | 76 |
77 public void getDigest(byte[] out) throws IOException { | 77 public void getDigest(byte[] out) throws IOException { |
78 try { | 78 try { |
79 getDigest(out, 0); | 79 getDigest(out, 0); |
80 } | 80 } |
81 catch(DigestException e) { | 81 catch (DigestException e) { |
82 throw new IOException(e); | 82 throw new IOException(e); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 public void getDigest(byte[] out, int off) throws DigestException { | 86 public void getDigest(byte[] out, int off) throws DigestException { |