John Mercier

[A software developer interested in java, groovy, and nixos]

Feb
20
2015

I have created a small project focused on the md5 algorithm. I noticed the md5 in java cannot be restarted. If my program is md5ing a large file, I need to start the process over again if the program crashes.

To solve this problem I created an MD5State which holdsĀ the state of the algorithm. A user can write this state to a file or database as bytes are being processed. If the program crashes the state can be recovered and processing can begin from where it left off.

I originally wrote this on google code ages ago but I wanted try using some of the other internet tools out there. I moved the project over to github and signed up for a travis-ci account. I created a cloud9 project to work on it through a browser. I even created some tests so travis-ci could failĀ builds if I messed something up.

I looked into installing this as a MessageDigest object in the java platform. It looks easy but I’m not sure if it is useful enough.

The test method is a good example of how to use this project. It takes a byte array and compares the md5 with the md5 from java.

` private boolean testAgainstJavaMD5(byte[] bytes) { MessageDigest expected = null; MD5MessageDigest test = null; try { expected = MessageDigest.getInstance("md5"); test = new MD5MessageDigest(); } catch (NoSuchAlgorithmException ex) { Logger.getLogger(MD5MessageDigestTest.class.getName()).log(Level.SEVERE, null, ex); throw new IllegalStateException("could not create MessageDigest", ex); } expected.update(bytes); String s = new BigInteger(1, expected.digest()).toString(16); if (s.length() == 31) { s = "0" + s; } test.digest(bytes); Logger.getLogger(MD5MessageDigestTest.class.getName()).info(s); Logger.getLogger(MD5MessageDigestTest.class.getName()).info(test.getState().toString()); return s.equals(test.getState().toString()); } `

Here are the links to the project.

2014 - 2018 | Mixed with Foundation v5.5.1 | Baked with JBake v2.5.1