File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
src/test/java/org/apache/commons/codec/digest Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ static byte[] toByteArray(final String binary) {
3434 throw new IllegalArgumentException (String .format ("Binary string length must be a multiple of %,d." , Byte .SIZE ));
3535 }
3636 final byte [] byteArray = new byte [inLen / Byte .SIZE ];
37- for (int i = 0 ; i < byteArray .length ; i += Byte .SIZE ) {
38- byteArray [i ] = (byte ) Integer .parseInt (binary .substring (i , i + Byte .SIZE ), RADIX );
37+ for (int i = 0 , j = 0 ; i < byteArray .length ; i ++, j += Byte .SIZE ) {
38+ byteArray [i ] = (byte ) Integer .parseInt (binary .substring (j , j + Byte .SIZE ), RADIX );
3939 }
4040 return byteArray ;
4141 }
Original file line number Diff line number Diff line change @@ -853,7 +853,7 @@ void testShaHex() throws IOException {
853853 void testShake128_256 (final String binaryInputText , final int inputBitSize , final String hexOutputText ) throws Exception {
854854 final String cleanBinary = clean (binaryInputText );
855855 final String cleanBinaryInput = StringUtils .reverse (cleanBinary );
856- final byte [] bytesInput = inputBitSize > 0 ? Binary .toByteArray (cleanBinaryInput ) : ArrayUtils . EMPTY_BYTE_ARRAY ;
856+ final byte [] bytesInput = Binary .toByteArray (cleanBinaryInput );
857857 // sanity check on the test fixture
858858 assertEquals (inputBitSize , bytesInput .length * Byte .SIZE );
859859 final String resultString = clean (hexOutputText ).substring (0 , SHAKE128_256_BYTE_LEN * 2 );
@@ -892,7 +892,7 @@ void testShake128_256_String() throws Exception {
892892 void testShake256_512 (final String binaryInputText , final int inputBitSize , final String hexOutputText ) throws Exception {
893893 final String cleanBinary = clean (binaryInputText );
894894 final String cleanBinaryInput = StringUtils .reverse (cleanBinary );
895- final byte [] bytesInput = inputBitSize > 0 ? Binary .toByteArray (cleanBinaryInput ) : ArrayUtils . EMPTY_BYTE_ARRAY ;
895+ final byte [] bytesInput = Binary .toByteArray (cleanBinaryInput );
896896 // sanity check on the test fixture
897897 assertEquals (inputBitSize , bytesInput .length * Byte .SIZE );
898898 final String resultString = clean (hexOutputText ).substring (0 , SHAKE128_512_BYTE_LEN * 2 );
You can’t perform that action at this time.
0 commit comments