Actually i did run into the bug immediately after.
I ended using org.apache.commons.codec.digest.DigestUtils#md5Hex from
apache which does a more careful job. Here are two test cases I used:
val name = "Stewie_Griffin.png"
val results =getUrlHashPart(name)
assertEquals("0/02/Stewie_Griffin.png", results)
val name = "Batman_Kane.jpg"
val results =getUrlHashPart(name)
assertEquals("0/00/Batman_Kane.jpg", results)
On Wed, Dec 7, 2011 at 1:34 PM, Mark Wagner <[email protected]> wrote:
> Have you considered how your code will perform if the MD5 checksum has
> *two* leading zeroes?
>
> --
> Mark
>
> On Mon, Dec 5, 2011 at 16:14, Tommy Chheng <[email protected]> wrote:
>> Thanks, here's a fix when the leading zero is being eaten:
>> val md5 = if (result.length % 2 != 0) "0" + result else result
>>
>> On Mon, Dec 5, 2011 at 3:37 PM, OQ <[email protected]> wrote:
>>> On Mon, Dec 5, 2011 at 5:33 PM, Tommy Chheng <[email protected]> wrote:
>>>> Thanks, i'll debug this some more. I'm using DBpedia's extraction code.
>>>>
>>>
>>>> val md5 = (new BigInteger(1, messageDigest)).toString(16)
>>>
>>> It's eating the leading zero when you're converting it to a BigInt.
>>> Not sure why, when AFAIK MessageDigest provides provides a toString method()
>
> _______________________________________________
> Mediawiki-api mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
--
@tommychheng
http://tommy.chheng.com
_______________________________________________
Mediawiki-api mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api