@Test public void shouldCreateCRC32Hash() throws IOException { InputStream inputStream = IOUtils.toInputStream("some string to hash"); Hasher adler32Hasher = new Adler32Hasher(); String hashedString = adler32Hasher.hash(inputStream); assertThat(hashedString, is("49420733")); }
@Override public String hash(InputStream inputStream) { byte[] buffer = new byte[128]; try (CheckedInputStream cis = new CheckedInputStream(inputStream, new Adler32())) { while (cis.read(buffer) >= 0) ; long checksum = cis.getChecksum().getValue(); return Long.toHexString(checksum); } catch (IOException ioe) { throw new RuntimeException("There was a problem reading the CheckedInputStream for the Adler32 algorithm", ioe); } }
Adler32Hasher implements Hasher { @Override public String hash(InputStream inputStream) { byte[] buffer = new byte[128]; try (CheckedInputStream cis = new CheckedInputStream(inputStream, new Adler32())) { while (cis.read(buffer) >= 0) ; long checksum = cis.getChecksum().getValue(); return Long.toHexString(checksum); } catch (IOException ioe) { throw new RuntimeException("There was a problem reading the CheckedInputStream for the Adler32 algorithm", ioe); } } }
Adler32Hasher implements Hasher { @Override public String hash(InputStream inputStream) { byte[] buffer = new byte[128]; try (CheckedInputStream cis = new CheckedInputStream(inputStream, new Adler32())) { while (cis.read(buffer) >= 0) ; long checksum = cis.getChecksum().getValue(); return Long.toHexString(checksum); } catch (IOException ioe) { throw new RuntimeException("There was a problem reading the CheckedInputStream for the Adler32 algorithm", ioe); } }  }
Adler32Hasher implements Hasher { @Override public String hash(InputStream inputStream) { byte[] buffer = new byte[128]; try (CheckedInputStream cis = new CheckedInputStream(inputStream, new Adler32())) { while (cis.read(buffer) >= 0) ; long checksum = cis.getChecksum().getValue(); return Long.toHexString(checksum); } catch (IOException ioe) { throw new RuntimeException("There was a problem reading the CheckedInputStream for the Adler32 algorithm", ioe); } }  @Override String hash(InputStream inputStream); }
Adler32Hasher implements Hasher { @Override public String hash(InputStream inputStream) { byte[] buffer = new byte[128]; try (CheckedInputStream cis = new CheckedInputStream(inputStream, new Adler32())) { while (cis.read(buffer) >= 0) ; long checksum = cis.getChecksum().getValue(); return Long.toHexString(checksum); } catch (IOException ioe) { throw new RuntimeException("There was a problem reading the CheckedInputStream for the Adler32 algorithm", ioe); } }  @Override String hash(InputStream inputStream);  }