Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How can we encrypt column value in talend Please help

Hi Team,
I need to encrypt particular attribute value .. how  can we achive this through talend .Please help me
Regards
Mohini Sharrmaa M
Labels (2)
6 Replies
Anonymous
Not applicable
Author

You can do this with a bit of Java in a tMap. Create a routine to encrypt your data (there are lots of examples here http://www.example-code.com/java/encryption.asp) and use the routine in a tMap. 
Anonymous
Not applicable
Author

Could you please give me the code if possible or function which I can use to call routine in tmap
thanks in Advance
Mohini
Anonymous
Not applicable
Author

First you need to create your routine. An example of a routine for encryption can be seen below (it's been a while since I wrote this and I am not certain it works)....
package routines;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.util.Formatter;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public class EncryptionUtilities {

private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";

private static String toHexString(byte[] bytes) {
Formatter formatter = new Formatter();

for (byte b : bytes) {
formatter.format("%02x", b);
}

return formatter.toString();
}

public static String calculateRFC2104HMAC(String data, String key)
throws SignatureException, NoSuchAlgorithmException, InvalidKeyException
{
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
mac.init(signingKey);
return toHexString(mac.doFinal(data.getBytes()));
}

}

To call this in the tMap you simply use the code.....
routines.EncryptionUtilities.calculateRFC2104HMAC(row1.data, "myKey")

....in the column you want to encrypt.
Please note that this is not meant for you to copy (you can, but it will need testing since it is a bit of code I quickly found on my machine), but as an example of how to do this.
Anonymous
Not applicable
Author

thank you so much
swambulkar
Contributor
Contributor

Is there decrypt method to allow for decryption of processed data set when needed?

Jesperrekuh
Specialist
Specialist

@mbocquet
Brute force.... or something really smart...
SHA stands for Secure Hash.
So SHA1 and MD5 aren't encryption algorythms, these are hashing and one way only.