commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
Subject [jira] [Commented] (CODEC-222) Fluent interface for HmacUtils
Date Sun, 22 May 2016 23:45:14 GMT


Sebb commented on CODEC-222:

The code now looks like:

byte[] hmac = HmacUtils.use(HmacAlgorithms.HMAC_MD5, key).hmac(valueToDigest);
If the enum is statically imported this becomes:
byte[] hmac = HmacUtils.use(HMAC_MD5, key).hmac(valueToDigest);

This is to be compared with the orginal:

byte[] hmac HmacUtils.hmacMd5(key, valueToDigest);

Similarly for Hex output:

String hmac = HmacUtils.use(HMAC_MD5, key).hmacHex(valueToDigest);
String hmac = HmacUtils.hmacMd5Hex(key, valueToDigest);

> Fluent interface for HmacUtils
> ------------------------------
>                 Key: CODEC-222
>                 URL:
>             Project: Commons Codec
>          Issue Type: New Feature
>            Reporter: Sebb
> As with DigestUtils, HmacUtils has lots of similar methods, differing only by their name.
> To simplify this, and unify the API for current standard and new algorithms, a fluent
approach is proposed. This still allows for using the enum values defined in HmacAlgorithms
but does not require the use of a different API for algorithms that are not supported by the
> The design is as for DigestUtils: create an instance of HmacUtils containing the Mac
to be updated, and provide chaining instance methods to update it and generate the output.

This message was sent by Atlassian JIRA

View raw message