Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
Can anyone suggest me, how to generate a hashcode using four business elements, which are coming from a source, am not familiar with java to write a routine for 4 business elements. i found a component taddCRCrow,but this can be used to get surrogate key not a hash code value, do we have any good component which can produce hash code, or else can any help me out how to write java code using 4 business elements, all this 4 attributes are string datatype
Thanks In Advance
Manish
Here is a piece of code you can use to generate a MD5 string from an input (called strCode):
package routines; import java.security.*; public class GetHashCode { public static String getMD5(String strCode) { java.security.MessageDigest msg; String digest1 = ""; try { msg = java.security.MessageDigest.getInstance("MD5"); msg.update(strCode.getBytes(), 0, strCode.length()); digest1 = new java.math.BigInteger(1, msg.digest()).toString(32); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } return digest1.toUpperCase(); } }
Create the routine and copy/past the code then start using it from anywhere in your jobs using the following expression:
GetHashCode.getMD5(row1.field1 + row1.field2 + row1.field3 + row1.field4)
Here is a piece of code you can use to generate a MD5 string from an input (called strCode):
package routines; import java.security.*; public class GetHashCode { public static String getMD5(String strCode) { java.security.MessageDigest msg; String digest1 = ""; try { msg = java.security.MessageDigest.getInstance("MD5"); msg.update(strCode.getBytes(), 0, strCode.length()); digest1 = new java.math.BigInteger(1, msg.digest()).toString(32); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } return digest1.toUpperCase(); } }
Create the routine and copy/past the code then start using it from anywhere in your jobs using the following expression:
GetHashCode.getMD5(row1.field1 + row1.field2 + row1.field3 + row1.field4)
@TRF Thank you so much for very swift response and it worked out.
Is it possible to get the result only in integers.