How can we encrypt column value in talend Please help

Six Stars

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
Highlighted
Community Manager

Re: How can we encrypt column value in talend Please help

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. 
Six Stars

Re: How can we encrypt column value in talend Please help

Could you please give me the code if possible or function which I can use to call routine in tmap
thanks in Advance
Mohini
Community Manager

Re: How can we encrypt column value in talend Please help

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.
Six Stars

Re: How can we encrypt column value in talend Please help

thank you so much
Four Stars

Re: How can we encrypt column value in talend Please help

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

Ten Stars

Re: How can we encrypt column value in talend Please help

@swambulkar
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.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog