List of utility methods to do Checksum Calculate
long | getChecksum(byte[] buffer, int offset, int length) get Checksum long result = 0; try { ByteArrayInputStream bais = new ByteArrayInputStream(buffer, offset, length); CheckedInputStream cis = new CheckedInputStream(bais, new Adler32()); byte readBuffer[] = new byte[length]; cis.read(readBuffer, 0, length); result = cis.getChecksum().getValue(); } catch (Exception e) { ... |
long | getChecksum(final File file) Returns the Adler32 checksum of the contents of a given File . if (file.isDirectory()) { return 0L; CheckedInputStream cis = null; try { cis = new CheckedInputStream(new FileInputStream(file), new Adler32()); final byte[] tempBuf = new byte[8192]; final Thread currentThread = Thread.currentThread(); ... |
String | getCheckSum(String filePath) Calculates the sha-256 hash of a file and returns the string value MessageDigest dig = MessageDigest.getInstance("sha-256"); byte[] bytes = Files.readAllBytes(Paths.get(filePath)); byte[] resDig = dig.digest(bytes); String b = DatatypeConverter.printHexBinary(resDig); return b.toLowerCase(); |
long | getChecksumAlder32(File file) get Checksum Alder BufferedInputStream bufferedInputStream = null; try { bufferedInputStream = new BufferedInputStream(new FileInputStream(file)); return getChecksumAlder32(bufferedInputStream); } catch (IOException e) { throw e; } finally { if (bufferedInputStream != null) { ... |
Map | getCheckSums(String archiveFile) get Check Sums Map<String, Long> checkSums = new HashMap<String, Long>(); ZipFile zipFile = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> e = zipFile.entries(); while (e.hasMoreElements()) { ZipEntry entry = e.nextElement(); checkSums.put(entry.getName(), entry.getCrc()); return checkSums; ... |