package com.ZetaOne.util; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class UNIDEncoder { public UNIDEncoder() { } public static String hex(byte[] array) { StringBuffer buff = new StringBuffer(); for (int b = 0; b < array.length; b++) { buff.append(Integer.toHexString((array[b] & 0xFF) | 0x100).substring(1, 3)); } return buff.toString().toUpperCase(); } public static String encode(String message) { try { MessageDigest md = MessageDigest.getInstance("MD5"); return hex(md.digest(message.getBytes("CP1252"))); } catch (NoSuchAlgorithmException e) { } catch (UnsupportedEncodingException e) { } return null; } }