D
douglasforrest
I need to match md5 outputs being generated by a java app which in
relevent part uses the following code:
byte[] digest = md.digest();
for (int i=0;i<digest.length;i++) {
hexString.append(Integer.toHexString(digest & 0xFF));
}
return hexString.toString();
where md is an instance of MessageDigest.getInstance("MD5");
Using a particular value to be encoded, this function returns the
31-digit hexedecimal string
a1ee2c082ee66978aeca3d377fd11a5
Using the perl Digest::MD5 md5_hex function on the same string returns
thie following 32-digit hexidecimal string, which is the same as the
java output with a leading "0" added.
0a1ee2c082ee66978aeca3d377fd11a5
I can't change the java so I am trying to to re-create the java results
using perl. I've been using various permutations of unpack and sprintf
on the 16-bit binary value generated by Digest::MD5 md5 without
success so far.
Any suggestions/pointers/ full-blown implementations would be much
appreciated!
relevent part uses the following code:
byte[] digest = md.digest();
for (int i=0;i<digest.length;i++) {
hexString.append(Integer.toHexString(digest & 0xFF));
}
return hexString.toString();
where md is an instance of MessageDigest.getInstance("MD5");
Using a particular value to be encoded, this function returns the
31-digit hexedecimal string
a1ee2c082ee66978aeca3d377fd11a5
Using the perl Digest::MD5 md5_hex function on the same string returns
thie following 32-digit hexidecimal string, which is the same as the
java output with a leading "0" added.
0a1ee2c082ee66978aeca3d377fd11a5
I can't change the java so I am trying to to re-create the java results
using perl. I've been using various permutations of unpack and sprintf
on the 16-bit binary value generated by Digest::MD5 md5 without
success so far.
Any suggestions/pointers/ full-blown implementations would be much
appreciated!