diff --git a/README.md b/README.md
index f24b409..49baa3c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# xxSherly
-A fork of [Sherly](https://github.com/BlyDoesCoding/Sherly), (not yet) using [xxHash](https://github.com/Cyan4973/xxHash).
+A fork of [Sherly](https://github.com/BlyDoesCoding/Sherly), using [xxHash](https://github.com/Cyan4973/xxHash).
## Introduction
@@ -24,7 +24,7 @@ Usage: sherly -f inputfolder1 inputfolder2 inputfolder3 [options]...
## Build
```bash
-mvn package
+mvn package assembly:single
```
## Supported Platforms
diff --git a/pom.xml b/pom.xml
index c8b03d7..d78e8dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,6 +20,11 @@
+
+ commons-codec
+ commons-codec
+ 1.15
+
@@ -40,8 +45,27 @@
3.8.0
- maven-surefire-plugin
- 2.22.1
+ maven-assembly-plugin
+ 3.5.0
+
+
+ jar-with-dependencies
+
+
+
+ net.chaoticbyte.xxsherly.App
+
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
maven-jar-plugin
@@ -54,23 +78,6 @@
-
- maven-install-plugin
- 2.5.2
-
-
- maven-deploy-plugin
- 2.8.2
-
-
-
- maven-site-plugin
- 3.7.1
-
-
- maven-project-info-reports-plugin
- 3.0.0
-
diff --git a/src/main/java/net/chaoticbyte/xxsherly/App.java b/src/main/java/net/chaoticbyte/xxsherly/App.java
index a3e0912..fe53f69 100644
--- a/src/main/java/net/chaoticbyte/xxsherly/App.java
+++ b/src/main/java/net/chaoticbyte/xxsherly/App.java
@@ -151,10 +151,10 @@ public class App {
for (String checksum: fileMap.keySet()) {
if (doTheColorThingy) {
- System.out.println(ConsoleColors.BLUE_BOLD + checksum + ConsoleColors.CYAN_BOLD + " --> " + ConsoleColors.GREEN_BOLD + fileMap.get(checksum) + ConsoleColors.RESET);
+ System.out.println(ConsoleColors.BLUE_BOLD + checksum + ConsoleColors.CYAN_BOLD + "\t--> " + ConsoleColors.GREEN_BOLD + fileMap.get(checksum) + ConsoleColors.RESET);
} else {
- System.out.println(checksum +" --> " + fileMap.get(checksum));
+ System.out.println(checksum +"\t--> " + fileMap.get(checksum));
}
}
diff --git a/src/main/java/net/chaoticbyte/xxsherly/ThreadedCompare.java b/src/main/java/net/chaoticbyte/xxsherly/ThreadedCompare.java
index 60aef15..1b97058 100644
--- a/src/main/java/net/chaoticbyte/xxsherly/ThreadedCompare.java
+++ b/src/main/java/net/chaoticbyte/xxsherly/ThreadedCompare.java
@@ -2,10 +2,10 @@ package net.chaoticbyte.xxsherly;
import java.io.*;
import java.nio.file.Path;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
+import java.util.zip.Checksum;
+import org.apache.commons.codec.digest.XXHash32;
public class ThreadedCompare extends Thread {
@@ -40,30 +40,26 @@ public class ThreadedCompare extends Thread {
//this is used to get the MD5 String of one of the files (one of them is just fine since they both have the same value)
private String getChecksum (File file) throws IOException {
- MessageDigest messageDigest = null;
- try {
- messageDigest = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- }
+ String digest = "";
+ // Calculate xxHash32 and add it's hexadecimal presentation to the digest
+
+ Checksum xxHash = new XXHash32();
FileInputStream inputStream = new FileInputStream(file);
-
byte[] dataBytes = new byte[1024];
int unread = 0;
while ((unread = inputStream.read(dataBytes)) != -1) {
- messageDigest.update(dataBytes, 0, unread);
+ xxHash.update(dataBytes, 0, unread);
}
-
inputStream.close();
+ digest += Long.toHexString(xxHash.getValue());
- // get digest & create hexadecimal represenation
- byte[] digestBytes = messageDigest.digest();
- StringBuilder stringBuilder = new StringBuilder();
- for (byte digestByte : digestBytes) {
- stringBuilder.append(Integer.toString((digestByte & 0xff) + 0x100, 16).substring(1));
- }
- return stringBuilder.toString();
+ // Add File length to the digest
+
+ digest += Long.toHexString(file.length());
+
+ // return result
+ return digest;
}
}