@Test public void hashThree() throws Exception { Map<HashAlgorithm, HashCode> hashes = Hashes.hash(ImmutableList.of(MD5, SHA1, SHA512), inputStream()); assertThat(hashes.size(), is(3)); assertThat(hashes.get(MD5).toString(), is(MD5_HASH)); assertThat(hashes.get(SHA1).toString(), is(SHA1_HASH)); assertThat(hashes.get(SHA512).toString(), is(SHA512_HASH)); }
public static HashCode hash(final HashAlgorithm algorithm, final InputStream inputStream) throws IOException { checkNotNull(algorithm); checkNotNull(inputStream); try (HashingInputStream hashingStream = new HashingInputStream(algorithm.function(), inputStream)) { ByteStreams.copy(hashingStream, ByteStreams.nullOutputStream()); return hashingStream.hash(); } }
Hashes { public static HashCode hash(final HashAlgorithm algorithm, final InputStream inputStream) throws IOException { checkNotNull(algorithm); checkNotNull(inputStream); try (HashingInputStream hashingStream = new HashingInputStream(algorithm.function(), inputStream)) { ByteStreams.copy(hashingStream, ByteStreams.nullOutputStream()); return hashingStream.hash(); } } }
Hashes { public static HashCode hash(final HashAlgorithm algorithm, final InputStream inputStream) throws IOException { checkNotNull(algorithm); checkNotNull(inputStream); try (HashingInputStream hashingStream = new HashingInputStream(algorithm.function(), inputStream)) { ByteStreams.copy(hashingStream, ByteStreams.nullOutputStream()); return hashingStream.hash(); } } private  Hashes(); }
Hashes { public static HashCode hash(final HashAlgorithm algorithm, final InputStream inputStream) throws IOException { checkNotNull(algorithm); checkNotNull(inputStream); try (HashingInputStream hashingStream = new HashingInputStream(algorithm.function(), inputStream)) { ByteStreams.copy(hashingStream, ByteStreams.nullOutputStream()); return hashingStream.hash(); } } private  Hashes(); static HashCode hash(final HashAlgorithm algorithm, final InputStream inputStream); static Map<HashAlgorithm, HashCode> hash(final Iterable<HashAlgorithm> algorithms,
                                                  final InputStream inputStream); static HashCode hash(final HashFunction function, final InputStream input); }
Hashes { public static HashCode hash(final HashAlgorithm algorithm, final InputStream inputStream) throws IOException { checkNotNull(algorithm); checkNotNull(inputStream); try (HashingInputStream hashingStream = new HashingInputStream(algorithm.function(), inputStream)) { ByteStreams.copy(hashingStream, ByteStreams.nullOutputStream()); return hashingStream.hash(); } } private  Hashes(); static HashCode hash(final HashAlgorithm algorithm, final InputStream inputStream); static Map<HashAlgorithm, HashCode> hash(final Iterable<HashAlgorithm> algorithms,
                                                  final InputStream inputStream); static HashCode hash(final HashFunction function, final InputStream input);  }