import java.io.*; import java.security.*; public class MessageDigestEncoder { static private byte [] loadByteData (String filename) { FileInputStream fis = null; try { fis = new FileInputStream (filename); BufferedInputStream bis = new BufferedInputStream (fis); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int ch; while ((ch = bis.read()) != -1) { baos.write (ch); } return baos.toByteArray(); } catch (IOException e) { if (fis != null) { try { fis.close(); } catch (IOException ee) { // ignore } } return null; } } static private String hexDigit(byte x) { StringBuffer sb = new StringBuffer(); char c; // First nibble c = (char) ((x >> 4) & 0xf); if (c > 9) { c = (char) ((c - 10) + 'a'); } else { c = (char) (c + '0'); } sb.append (c); // Second nibble c = (char) (x & 0xf); if (c > 9) { c = (char)((c - 10) + 'a'); } else { c = (char)(c + '0'); } sb.append (c); return sb.toString(); } static private String computeDigest (MessageDigest algorithm, String filename) { byte[] content = loadByteData (filename); if (content != null) { algorithm.reset(); algorithm.update (content); byte digest[] = algorithm.digest(); StringBuffer hexString = new StringBuffer(); int digestLength = digest.length; for (int i=0;i