
Creator
2011-12-21
10:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sha1 hash key
i need to generate hash key with sha1 algorithm how can we do it with java code or sqlserver query
276 Views
3 Replies

Anonymous
Not applicable
2011-12-22
12:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
276 Views

Anonymous
Not applicable
2016-04-12
02:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
276 Views

Anonymous
Not applicable
2016-04-12
03:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
}
}
public static String getSHA256(String field) {
if(field == null) 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;
}
}
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;
}
}
public static String getSHA256(String field) {
if(field == null) 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;
}
}
276 Views
