commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julius Davies (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CODEC-87) DigestUtils: MD5 checksum is not calculated correctly on linux64-platforms
Date Fri, 11 Sep 2009 16:28:57 GMT

    [ https://issues.apache.org/jira/browse/CODEC-87?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12754199#action_12754199
] 

Julius Davies commented on CODEC-87:
------------------------------------

I created the following Java class to test this:

{code}
import org.apache.commons.codec.digest.*;

public class Codec87 {

  public static void main(String[] args) {
    String osName = System.getProperty("os.name");
    String osArch = System.getProperty("os.arch");
    String osVersion = System.getProperty("os.version");

    System.out.println(DigestUtils.md5Hex("a9P,+$") + " " + osName + " " + osArch + " " +
osVersion);
  }
}
{code}




$ echo -n "a9P,+$" | md5sum
----------------------------------------
f13ba39d06128b53b2bd238dfd357bcf  -

java -cp commons-codec-1.4.jar:. Codec87
----------------------------------------
f13ba39d06128b53b2bd238dfd357bcf Linux        ppc   2.6.30-1-powerpc
f13ba39d06128b53b2bd238dfd357bcf Linux        amd64 2.6.30-1-amd64
f13ba39d06128b53b2bd238dfd357bcf Windows 2000 x86   5.0


The results were the same for me using Codec-1.3 and Codec-1.4.  This is the same result Henri
(OSX) and Sebb (Perl) obtained.  Notice my first result came from md5sum unix command.




> DigestUtils: MD5 checksum is not calculated correctly on linux64-platforms
> --------------------------------------------------------------------------
>
>                 Key: CODEC-87
>                 URL: https://issues.apache.org/jira/browse/CODEC-87
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.3, 1.4
>         Environment: Suse Enterprise Linux 10 (64bit)
>            Reporter: Alexander Gräf
>
> Actual behaviour: 
> The class DigesterUtils calculates different md5-hashes depending on plattform.
> I used jdk1.5.0_19-32bit on win32 and jdk1.5.0_19-64bit on SLES 10 (64-bit) for testing.

> The effect depends on the charactersequence that is used for the calculation of the hash.
There are some charactersequences that are calculated correctly. I think that the hash that
is calculated on Windows 32 is the correct one since we have checked it by using an other
library for calculating md5-hashes (Tagish-Auth-1.0.3). Since both of the tested libraries
internally make use of the class java.security.MessageDigest but differ in the way the calculated
byte[] is transformed in a hex-string, I think that the problem is located in the Hex.encodeHex(byte[]
hashedBytes) method.
> Expected behaviour: 
> The md5-hash should should not depend on the platform and should be equal for all platforms.
> Testcase:
> System.out.println(DigestUtils.md5Hex("a9P,+$")); 
> produces the hash 79c28faa4fec5ceb98137f548f1d6fe3 on Windows XP (32bit).
> The same instruction produces 3191078c1fa327f9856b5b54628f2a39 on Suse Enterprise Linux
10 (64bit).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message