-1

I am trying to generate MD5 checksum value using java for a string "TREFFLAGDATAC000000EN", but for the same string the IBM InfoSphere DataStage is generating a differnt MD5 checksum value.

Can anyone please direct me on how to generate the same MD5 checksum value given by data stage?

md5 generated by java code: 4659dff22b357cd9cc9fe0979603d1ab md5 generated by data stage: fd607ac2a5d19980795c584dff24b899

below is my java code

public static void main(String[] args) throws UnsupportedEncodingException{ String value = "TREFFLAGDATAC000000EN"; String hashCode = DigestUtils.md5Hex(value.getBytes("UTF-8")); System.out.println(hashCode); }

Barney
  • 2,786
  • 2
  • 32
  • 34
  • Well currently your code is platform-specific - you're using `value.getBytes()` which will use the platform-default encoding to convert the text into bytes. That's probably not the issue, but it's *a* potential issue. You're also calling `toString()` on a string, which is odd. And `value` in your sample code is the empty string, not "TREFFLAGDATAC000000EN". – Jon Skeet Apr 02 '14 at 09:44
  • thanks for your reply Jon. I have now updated my code with string values. – user3488451 Apr 02 '14 at 10:18

2 Answers2

0

You should try this http://www.asjava.com/core-java/java-md5-example/

I think you should chage vlaues to String data type at end of source code. You will find a sample in abouve link.

  • Thanks for you reply. With the code you have shared i am still getting the same MD5 value. But its not matching with the MD5 checksum value generated by Data Stage tool. MD5 generated by java code: 4659dff22b357cd9cc9fe0979603d1ab MD5 generated by Data Stage: fd607ac2a5d19980795c584dff24b899 is there any scenarios where MD5 algorithm being different between java and data stage? – user3488451 Apr 02 '14 at 10:25
0

You can debug DataStage Checksum looking at Buffer contents... Actually, DataStage Checksum stage just adds "|" sigh at the end of your string, and so... =)