# perldoc > Digest::HMAC_MD5

---
type: CommandReference
command: Digest::HMAC_MD5
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference

- `hmac_md5($data, $key)` — functional interface, returns raw digest
- `hmac_md5_hex($data, $key)` — functional interface, returns hex digest
- `Digest::HMAC_MD5->new($key)` — create new HMAC-MD5 object with key
- `$hmac->add($data)` — add data to digest
- `$hmac->addfile(*FILE)` — add data from filehandle
- `$hmac->digest` — return raw binary digest
- `$hmac->hexdigest` — return hex digest
- `$hmac->b64digest` — return base64 digest

## Name

Digest::HMAC_MD5 - Keyed-Hashing for Message Authentication

## Synopsis

perl
# Functional style
use Digest::HMAC_MD5 qw(hmac_md5 hmac_md5_hex);
$digest = hmac_md5($data, $key);
print hmac_md5_hex($data, $key);

# OO style
use Digest::HMAC_MD5;
$hmac = Digest::HMAC_MD5->new($key);

$hmac->add($data);
$hmac->addfile(*FILE);

$digest = $hmac->digest;
$digest = $hmac->hexdigest;
$digest = $hmac->b64digest;
## Description

This module provides HMAC-MD5 hashing.

## Options

- `hmac_md5($data, $key)` — functional interface, returns raw binary digest
- `hmac_md5_hex($data, $key)` — functional interface, returns hex-encoded digest
- `Digest::HMAC_MD5->new($key)` — constructor, creates a new HMAC-MD5 object with the given key
- `$hmac->add($data)` — add data to the digest calculation
- `$hmac->addfile(*FILE)` — add data from an open filehandle
- `$hmac->digest` — return the raw binary digest
- `$hmac->hexdigest` — return the hex-encoded digest
- `$hmac->b64digest` — return the base64-encoded digest

## Examples

perl
use Digest::HMAC_MD5 qw(hmac_md5_hex);
my $key = "secret";
my $data = "message";
my $hex = hmac_md5_hex($data, $key);
print $hex;  # prints HMAC-MD5 hex digest
## See Also

[Digest::HMAC](https://www.chedong.com/phpMan.php/perldoc/Digest%3A%3AHMAC/markdown), [Digest::MD5](https://www.chedong.com/phpMan.php/perldoc/Digest%3A%3AMD5/markdown), [Digest::HMAC_SHA1](https://www.chedong.com/phpMan.php/perldoc/Digest%3A%3AHMACSHA1/markdown)

## Exit Codes

(Not documented)