You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/10/05 23:56:40 UTC

(commons-codec) branch master updated: Add support for SHAKE128-256 and SHAKE256-512 to `DigestUtils` and `MessageDigestAlgorithms` on Java 25 and up

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git


The following commit(s) were added to refs/heads/master by this push:
     new 1c5f484e Add support for SHAKE128-256 and SHAKE256-512 to `DigestUtils` and `MessageDigestAlgorithms` on Java 25 and up
1c5f484e is described below

commit 1c5f484ee7d1e16c94450149223833b6f7977ab6
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 5 19:56:34 2025 -0400

    Add support for SHAKE128-256 and SHAKE256-512 to `DigestUtils` and
    `MessageDigestAlgorithms` on Java 25 and up
---
 src/test/java/org/apache/commons/codec/digest/Binary.java          | 4 ++--
 src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/digest/Binary.java b/src/test/java/org/apache/commons/codec/digest/Binary.java
index c9a09396..f98d4fd0 100644
--- a/src/test/java/org/apache/commons/codec/digest/Binary.java
+++ b/src/test/java/org/apache/commons/codec/digest/Binary.java
@@ -34,8 +34,8 @@ class Binary {
             throw new IllegalArgumentException(String.format("Binary string length must be a multiple of %,d.", Byte.SIZE));
         }
         final byte[] byteArray = new byte[inLen / Byte.SIZE];
-        for (int i = 0; i < byteArray.length; i += Byte.SIZE) {
-            byteArray[i] = (byte) Integer.parseInt(binary.substring(i, i + Byte.SIZE), RADIX);
+        for (int i = 0, j = 0; i < byteArray.length; i++, j += Byte.SIZE) {
+            byteArray[i] = (byte) Integer.parseInt(binary.substring(j, j + Byte.SIZE), RADIX);
         }
         return byteArray;
     }
diff --git a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
index 3c5a8f34..37548fb8 100644
--- a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
@@ -853,7 +853,7 @@ class DigestUtilsTest {
     void testShake128_256(final String binaryInputText, final int inputBitSize, final String hexOutputText) throws Exception {
         final String cleanBinary = clean(binaryInputText);
         final String cleanBinaryInput = StringUtils.reverse(cleanBinary);
-        final byte[] bytesInput = inputBitSize > 0 ? Binary.toByteArray(cleanBinaryInput) : ArrayUtils.EMPTY_BYTE_ARRAY;
+        final byte[] bytesInput = Binary.toByteArray(cleanBinaryInput);
         // sanity check on the test fixture
         assertEquals(inputBitSize, bytesInput.length * Byte.SIZE);
         final String resultString = clean(hexOutputText).substring(0, SHAKE128_256_BYTE_LEN * 2);
@@ -892,7 +892,7 @@ class DigestUtilsTest {
     void testShake256_512(final String binaryInputText, final int inputBitSize, final String hexOutputText) throws Exception {
         final String cleanBinary = clean(binaryInputText);
         final String cleanBinaryInput = StringUtils.reverse(cleanBinary);
-        final byte[] bytesInput = inputBitSize > 0 ? Binary.toByteArray(cleanBinaryInput) : ArrayUtils.EMPTY_BYTE_ARRAY;
+        final byte[] bytesInput = Binary.toByteArray(cleanBinaryInput);
         // sanity check on the test fixture
         assertEquals(inputBitSize, bytesInput.length * Byte.SIZE);
         final String resultString = clean(hexOutputText).substring(0, SHAKE128_512_BYTE_LEN * 2);