Example usage for org.apache.commons.codec.digest HmacUtils hmacMd5

List of usage examples for org.apache.commons.codec.digest HmacUtils hmacMd5

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest HmacUtils hmacMd5.

Prototype

public static byte[] hmacMd5(final String key, final String valueToDigest) 

Source Link

Document

Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value.

Usage

From source file:com.vmware.o11n.plugin.crypto.service.CryptoDigestService.java

/**
 * HmacMD5/*from w w  w  . j av a 2 s .  c o m*/
 *
 * @param keyB64 Secret key Base64 encoded
 * @param dataB64 Data to sign Base64 encoded
 * @return HmacMd5 MAC for the given key and data Base64 encoded
 */
public String hmacMd5(String keyB64, String dataB64) {
    validateB64(keyB64);
    validateB64(dataB64);
    final byte[] key = Base64.decodeBase64(keyB64);
    final byte[] data = Base64.decodeBase64(dataB64);

    return Base64.encodeBase64String(HmacUtils.hmacMd5(key, data));
}