From 81c790e0334dc167026a7a44c88f27f13af56568 Mon Sep 17 00:00:00 2001
From: Osiris-Team <59899645+Osiris-Team@users.noreply.github.com>
Date: Mon, 4 Jul 2022 18:53:34 +0200
Subject: [PATCH 1/6] Added fastSHA512, fastSHA256 and fastSHA1 methods
---
.../util/EncryptionUtilities.java | 61 +++++++++++++++++--
1 file changed, 57 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/cedarsoftware/util/EncryptionUtilities.java b/src/main/java/com/cedarsoftware/util/EncryptionUtilities.java
index e73c197e..c9b974de 100644
--- a/src/main/java/com/cedarsoftware/util/EncryptionUtilities.java
+++ b/src/main/java/com/cedarsoftware/util/EncryptionUtilities.java
@@ -41,7 +41,7 @@ private EncryptionUtilities()
}
/**
- * Super-fast MD5 calculation from entire file. Uses FileChannel and
+ * Super-fast MD5 calculation from entire file. Uses FileChannel and
* direct ByteBuffer (internal JVM memory).
* @param file File that from which to compute the MD5
* @return String MD5 value.
@@ -50,7 +50,61 @@ public static String fastMD5(File file)
{
try (FileInputStream in = new FileInputStream(file))
{
- return calculateMD5Hash(in.getChannel());
+ return calculateFileHash(in.getChannel(), getMD5Digest());
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Super-fast SHA-1 calculation from entire file. Uses FileChannel and
+ * direct ByteBuffer (internal JVM memory).
+ * @param file File that from which to compute the SHA-1
+ * @return String SHA-1 value.
+ */
+ public static String fastSHA1(File file)
+ {
+ try (FileInputStream in = new FileInputStream(file))
+ {
+ return calculateFileHash(in.getChannel(), getSHA1Digest());
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Super-fast SHA-256 calculation from entire file. Uses FileChannel and
+ * direct ByteBuffer (internal JVM memory).
+ * @param file File that from which to compute the SHA-256
+ * @return String SHA-256 value.
+ */
+ public static String fastSHA256(File file)
+ {
+ try (FileInputStream in = new FileInputStream(file))
+ {
+ return calculateFileHash(in.getChannel(), getSHA256Digest());
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Super-fast SHA-512 calculation from entire file. Uses FileChannel and
+ * direct ByteBuffer (internal JVM memory).
+ * @param file File that from which to compute the SHA-512
+ * @return String SHA-512 value.
+ */
+ public static String fastSHA512(File file)
+ {
+ try (FileInputStream in = new FileInputStream(file))
+ {
+ return calculateFileHash(in.getChannel(), getSHA512Digest());
}
catch (IOException e)
{
@@ -58,10 +112,9 @@ public static String fastMD5(File file)
}
}
- public static String calculateMD5Hash(FileChannel ch) throws IOException
+ public static String calculateFileHash(FileChannel ch, MessageDigest d) throws IOException
{
ByteBuffer bb = ByteBuffer.allocateDirect(65536);
- MessageDigest d = getMD5Digest();
int nRead;
From a96d6ee5333b29ce41dfc31d0b572c992498a912 Mon Sep 17 00:00:00 2001
From: Osiris-Team <59899645+Osiris-Team@users.noreply.github.com>
Date: Mon, 4 Jul 2022 19:05:23 +0200
Subject: [PATCH 2/6] Create build-maven.yml
---
.github/workflows/build-maven.yml | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 .github/workflows/build-maven.yml
diff --git a/.github/workflows/build-maven.yml b/.github/workflows/build-maven.yml
new file mode 100644
index 00000000..825103e8
--- /dev/null
+++ b/.github/workflows/build-maven.yml
@@ -0,0 +1,26 @@
+# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
+
+name: Java CI with Maven
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: '11'
+ distribution: 'temurin'
+ cache: maven
+ - name: Build with Maven
+ run: mvn -B package --file pom.xml
From ec6a4cfad6d82c8d244cfcbc804f8f83353e85c6 Mon Sep 17 00:00:00 2001
From: Osiris-Team <59899645+Osiris-Team@users.noreply.github.com>
Date: Mon, 4 Jul 2022 19:09:57 +0200
Subject: [PATCH 3/6] Update TestEncryption.java
---
src/test/java/com/cedarsoftware/util/TestEncryption.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/test/java/com/cedarsoftware/util/TestEncryption.java b/src/test/java/com/cedarsoftware/util/TestEncryption.java
index 568ae161..322eaaf3 100644
--- a/src/test/java/com/cedarsoftware/util/TestEncryption.java
+++ b/src/test/java/com/cedarsoftware/util/TestEncryption.java
@@ -111,7 +111,7 @@ public void testFastMd50BytesReturned() throws Exception {
FileChannel f = mock(FileChannel.class);
when(f.read(any(ByteBuffer.class))).thenReturn(0).thenReturn(-1);
- EncryptionUtilities.calculateMD5Hash(f);
+ EncryptionUtilities.calculateFileHash(f, EncryptionUtilities.getMD5Digest());
}
From 86ec94e2e2c73f2340bfa037d004a74c34962f9c Mon Sep 17 00:00:00 2001
From: Osiris-Team <59899645+Osiris-Team@users.noreply.github.com>
Date: Mon, 4 Jul 2022 22:31:09 +0200
Subject: [PATCH 4/6] Update pom.xml
fix compatibility with jitpack.io
---
pom.xml | 145 --------------------------------------------------------
1 file changed, 145 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4cabdc96..3c064f9e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,55 +9,6 @@
Java Utilities
https://github.com/jdereg/java-util
-
-
-
- release-sign-artifacts
-
-
- performRelease
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- ${version.plugin.gpg}
-
-
- sign-artifacts
- verify
-
- sign
-
-
- ${gpg.keyname}
- ${gpg.passphrase}
-
-
-
-
-
-
-
-
-
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
-
-
- https://github.com/jdereg/java-util
- scm:git:git://github.com/jdereg/java-util.git
- scm:git:git@github.com:jdereg/java-util.git
-
-
jdereg
@@ -95,102 +46,6 @@
-
-
-
- org.apache.felix
- maven-scr-plugin
- ${version.plugin.felix.scr}
-
-
-
- org.apache.felix
- maven-bundle-plugin
- ${version.plugin.felix.bundle}
- true
-
-
- com.cedarsoftware.util
- *
-
-
-
-
- bundle-manifest
-
-
- manifest
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${version.plugin.compiler}
-
- 11
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- ${version.plugin.source}
-
-
- attach-sources
-
- jar-no-fork
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- ${version.plugin.javadoc}
-
- -Xdoclint:none
- -Xdoclint:none
-
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- ${version.plugin.nexus}
- true
-
- ossrh
- https://oss.sonatype.org/
- true
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${version.plugin.surefire}
-
- 0
-
-
-
-
-
-
org.slf4j
From 34355e88dd9695d510e62428c6896d78e184f660 Mon Sep 17 00:00:00 2001
From: Osiris-Team <59899645+Osiris-Team@users.noreply.github.com>
Date: Mon, 4 Jul 2022 22:35:56 +0200
Subject: [PATCH 5/6] Update pom.xml
---
pom.xml | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/pom.xml b/pom.xml
index 3c064f9e..bd6f7da7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,6 +45,102 @@
https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+
+
+ org.apache.felix
+ maven-scr-plugin
+ ${version.plugin.felix.scr}
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ ${version.plugin.felix.bundle}
+ true
+
+
+ com.cedarsoftware.util
+ *
+
+
+
+
+ bundle-manifest
+
+
+ manifest
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${version.plugin.compiler}
+
+ 11
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ ${version.plugin.source}
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ ${version.plugin.javadoc}
+
+ -Xdoclint:none
+ -Xdoclint:none
+
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ ${version.plugin.nexus}
+ true
+
+ ossrh
+ https://oss.sonatype.org/
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${version.plugin.surefire}
+
+ 0
+
+
+
+
+
From a9a8bc3568770171909de77393ba7979de23e04f Mon Sep 17 00:00:00 2001
From: Osiris-Team <59899645+Osiris-Team@users.noreply.github.com>
Date: Mon, 4 Jul 2022 23:33:35 +0200
Subject: [PATCH 6/6] Update pom.xml
---
pom.xml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/pom.xml b/pom.xml
index bd6f7da7..8b68f974 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,6 +34,55 @@
1.0.7
UTF-8
+
+
+
+
+ release-sign-artifacts
+
+
+ performRelease
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ ${version.plugin.gpg}
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+ ${gpg.keyname}
+ ${gpg.passphrase}
+
+
+
+
+
+
+
+
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ https://github.com/jdereg/java-util
+ scm:git:git://github.com/jdereg/java-util.git
+ scm:git:git@github.com:jdereg/java-util.git
+