<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/HMAC/authenticationCode(for:using:)-heea",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit4HMACV18authenticationCode3for5usingAA020HashedAuthenticationE0VyxGs7RawSpanV_AA12SymmetricKeyVtFZ"
  },
  "title" : "authenticationCode(for:using:)"
}
-->

# authenticationCode(for:using:)

Computes a message authentication code for the given data.

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

## Parameters

`data`

The data for which to compute the authentication code.

`key`

The symmetric key used to secure the computation.

## Return Value

The message authentication code.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)