Question

2
Replies
376
Views
BISWAJIT-2 Member since 2010 21 posts
Tata Consultancy Services
Posted: August 3, 2016
Last activity: August 4, 2016
Closed
Solved

How to import java.Security.MessageDigest

Hi I have a requirement to write a java that requires the above referenced library. How can I make this library available to my java activity step please. What are the other alternatives, if there is any, I can use to do this work. I was looking and found I need a .Jar file for the abobe java class. If so whare can I get the .jar file. The java is as below. Many thanks.

 

String clientRef;

String transactionRef;

String amount;

String securityKey;

 

String input = clientRef + ";" + transactionRef + ";" + amount + ";" + securityKey;

java.Security.MessageDigest digest = java.Security.MessageDigest.getInstance("SHA-256");

byte[] hash = digest.digest(input.getBytes("UTF-8"));

StringBuffer hexString = new StringBuffer();

 

 

for (int i = 0; i < hash.length; i++) {

             String hex = Integer.toHexString(0xff & hash[i]);

              if(hex.length() == 1 && hexString.length()>0) hexString.append('0');

               hexString.append(hex);}

 

 

String returnValue = hexString.toString();

 

***Updated by moderator: Lochan to add Categories***

Data Integration Java and Activities
Moderation Team has archived post
Share this page LinkedIn