@SuppressWarnings("deprecation") @Test public void hashStreamWithFunction() throws Exception { byte[] bytes = DATA.getBytes(StandardCharsets.UTF_8); String expected = Hashing.sha1().hashBytes(bytes).toString(); HashCode found = Hashes.hash(Hashing.sha1(), new ByteArrayInputStream(bytes)); assertThat(found.toString(), is(expected)); }
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);  }