Hi everybody I am trying to implement the MD5 algorithm in the Java Snippet Node, but I am unable to run it succesfully.
More specifically I want to "hash" a column and return the MD5 version of that column, to "anonymize" the information of that column.
I found the Java Code in a bunch of websites and I particulary liked this one http://bit.ly/29x4uY6. The code is bellow and also I am attaching a workflow with my attempt.
Any help will be appreciated
Best regards
import java.io.FileInputStream; import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class MD5 { public static String getMD5(String input) { try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] messageDigest = md.digest(input.getBytes()); BigInteger number = new BigInteger(1, messageDigest); String hashtext = number.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 (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } public static void main(String[] args) throws NoSuchAlgorithmException { System.out.println(getMD5("Javarmi.com")); } }