Both the library itself and many of its tests are utterly dependent on the JVM's default charset. For example, DigestUtils calls String.getBytes() to convert an input string to a byte array, happily delivering different digests for the same input string if run on different platforms.
If you want to try out the havor yourself, just run the unit tests in a JVM with UTF-16, e.g. by adding the line
<argLine>-Dfile.encoding=UTF-16</argLine>
to the configuration of the Surefire Plugin in the POM.
Description
Both the library itself and many of its tests are utterly dependent on the JVM's default charset. For example, DigestUtils calls String.getBytes() to convert an input string to a byte array, happily delivering different digests for the same input string if run on different platforms.
If you want to try out the havor yourself, just run the unit tests in a JVM with UTF-16, e.g. by adding the line
<argLine>-Dfile.encoding=UTF-16</argLine>
to the configuration of the Surefire Plugin in the POM.
Sebb added a comment - 14/Jul/08 11:19 AM Agreed that the default charset dependency needs to be removed.
However, I have an alternative suggestion:
In the case of the Hex encode() method, one could completely avoid the need to use getBytes() by using a byte[] array for the conversion.
Likewise, I think the Hex decode() could just be performed on bytes rather than converting to char first.
Patch to follow.
However, I have an alternative suggestion:
In the case of the Hex encode() method, one could completely avoid the need to use getBytes() by using a byte[] array for the conversion.
Likewise, I think the Hex decode() could just be performed on bytes rather than converting to char first.
Patch to follow.