Fixed MD5 calculation when there are leading zeros

This commit is contained in:
Ciaran Gultnieks 2010-11-06 14:42:46 +00:00
parent 918aa224cb
commit aed9066347

View File

@ -32,6 +32,12 @@ public class Md5Handler {
byte[] md5sum = digest.digest(); byte[] md5sum = digest.digest();
BigInteger bigInt = new BigInteger(1, md5sum); BigInteger bigInt = new BigInteger(1, md5sum);
md5hash = bigInt.toString(16); md5hash = bigInt.toString(16);
// We need 32 hex digits - add leading zeros in an inefficient and
// brute-force manner...
while (md5hash.length() < 32)
md5hash = "0" + md5hash;
} catch (Exception e) { } catch (Exception e) {
} }