Hi You can create Routine(hard code Java class and methods) in 'Repository-Code-Routines'. Then call the methods of Java SHA1 implement in Talend components such as tMap, tJava and so on. Hope this will help you. Best regards! Pedro
Hi, I am new to Talend and i had the same query like i have to generate hash key using SHA-1 Algorithm.So please provide me the detailed process of doing it... Thanks
Here's some examples of methods that you can add to a Talend routine, for doing this.
public static String getMD5(String field) {
if(field == null) return null;
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
md.reset();
md.update(field.getBytes("UTF-8"));
byte[] digest = md.digest();
java.math.BigInteger bigInt = new java.math.BigInteger(1, digest);
String hashText = bigInt.toString(16);
// Now we need to zero pad it if you actually want the full 32 chars.
while(hashText.length() < 32 ){
hashText = "0" + hashText;
}
return hashText;
}
catch (Exception e) {
return null;
}
}
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-256");
md.reset();
md.update(field.getBytes("UTF-8"));
byte[] digest = md.digest();
java.math.BigInteger bigInt = new java.math.BigInteger(1, digest);
String hashText = bigInt.toString(16);
// Now we need to zero pad it if you actually want the full 32 chars.
while(hashText.length() < 32 ){
hashText = "0" + hashText;
}
return hashText;
}
catch (Exception e) {
return null;
}
}