---
title: "authenticationCode(for:using:)"
framework: cryptokit
role: symbol
role_heading: Type Method
path: "cryptokit/hmac/authenticationcode(for:using:)-737ab"
---

# authenticationCode(for:using:)

Computes a message authentication code for the given data.

## Declaration

```swift
static func authenticationCode<D>(for data: D, using key: SymmetricKey) -> HMAC<H>.MAC where D : DataProtocol
```

## Parameters

- `data`: The data for which to compute the authentication code.
- `key`: The symmetric key used to secure the computation.

## Return Value

Return Value The message authentication code.
