Add methods to DigestUtils to generate hex from MessageDigest et. al. by sesuncedu · Pull Request #8 · apache/commons-codec (original) (raw)

Conversation

@sesuncedu

This PR replaces #7 which was associated with the wrong issue number
This PR adds methods to DigestUtils to make it easy to generate hexadecimal strings from:

[Although clone is optional for MessageDigests, it seems to be almost universally supported (e.g. both the Sun and the IBM providers implement clone for their concrete digests) ]

Signed-off-by: Simon Spero sesuncedu@gmail.com

@sesuncedu

…ssageDigest, a DigestInputStream, or a DigestOutputStream. If the underlying digest implementation implements clone, a clone will be created before extracting the digest to avoid resetting it.

Signed-off-by: Simon Spero sesuncedu@gmail.com

garydgregory

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch ! Can you split up the tests so that each new API gets its own test method please?

@sesuncedu

WILCO. I will assume 1. the intended granularity of "new API" is one test method for each added API method and; 2. that it if there is an assertion failure in an API method that is used by another API method, it is possibly but not necessarily the case that a corresponding assertion failure be signaled in the test for the calling method. (ie redundant, duplicate checks are OK, but the test of the dependent method may error due to exceptions, etc. Also, did you know: there are a lot of methods in digestutils :)

@garydgregory

Go for it.

Lots of methods? You should see StringUtils in Apache Commons Lang! ;-)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})