Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to generate MD5 hash value

Hi All,
I want to generate MD5 checksum value to compare source and target data for all input columns. So that I can update the data in Target table only when there is change in Checksum value else reject. I goggle for user-defined routines but nothing helped.
I am very new to Talend and dont have much knowledge even on Java.
Helpful if someone could provide steps to do my job.
Regards
Keerthi

Labels (3)
1 Solution

Accepted Solutions
6 Replies
Anonymous
Not applicable
Author

You will need to use Java for this. This cannot really be made "easy" I'm afraid. Take a look here.....

https://www.quickprogrammingtips.com/java/how-to-generate-md5-hash-in-java.html

 

Referring to this I have put together a method that you can add to a routine.....

 

public static String getMD5(String data){
            java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
            byte[] hash = digest.digest(data.getBytes("UTF-8"));

            return javax.xml.bind.DatatypeConverter.printHexBinary(hash);
}
Anonymous
Not applicable
Author

Thank you very much for your prompt response. I created the java routine in Talend using your code but unable to view under CATEGORIES.

How can I call the routine, how to pass input columns into the routine and how to compare them with the target/LKP table chksm value ? I tried using it in TMap but unable to proceed. Could you please help me.

Regards,

Keerthi

 

 

Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

Thank You for the inputs @rhall. I modified the java code to suit my requirement and it worked.

RAJ6
Contributor III
Contributor III

Hi keerthy,

 

How to do this MD5 checksum value to compare source and target data for all input columns. please share your information step by step and also share your java code.

 

KarthikGs
Creator
Creator

hi Keerthi can you share how you solved the problem?