Encription SHA in Pentaho Data Integration (Spoon)

we often use Pentaho Data Integration a.k.a spoon as tool for data migration, and migrating user account with generated password is just a task among the others. this blog post share you how to create a SHA encripted string, used to store generated password.

to convert string into SHA encripted password we can use Java Script Value step. here is javascript code to calculate SHA encription:

// simulate java imports
var MessageDigest = java.security.MessageDigest;
var String = java.lang.String;
var StringBuffer = java.lang.StringBuffer;
var Integer = java.lang.Integer;
 
// get the md5 digest algorithm
var algorithm = MessageDigest.getInstance("SHA");
 
// get the input as bytes
var bytes = new String(unhash_password.getString()).getBytes("UTF-8");
 
// calculate the digest
algorithm.reset();
algorithm.update(bytes);
var md5Digest = algorithm.digest();

var encString = new Packages.java.lang.String( Packages.org.apache.commons.codec.binary.Base64.encodeBase64( md5Digest ) );

the spoon transformation should like below:

and, the result:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s