<!--
{
  "availability" : [
    "iOS: 13.2.0 -",
    "iPadOS: 13.2.0 -",
    "macCatalyst: 13.2.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.2.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/HMAC/isValidAuthenticationCode(_:authenticating:using:)-5ilt9",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit4HMACV25isValidAuthenticationCode_14authenticating5usingSbqd___qd_0_AA12SymmetricKeyVt10Foundation15ContiguousBytesRd__AI12DataProtocolRd_0_r0_lFZ"
  },
  "title" : "isValidAuthenticationCode(_:authenticating:using:)"
}
-->

# isValidAuthenticationCode(_:authenticating:using:)

Returns a Boolean value indicating whether the given message
authentication code represented as contiguous bytes is valid for a block
of data.

```
static func isValidAuthenticationCode<C, D>(_ authenticationCode: C, authenticating authenticatedData: D, using key: SymmetricKey) -> Bool where C : ContiguousBytes, D : DataProtocol
```

## Parameters

`authenticationCode`

The authentication code to compare.

`authenticatedData`

The block of data to compare.

`key`

The symmetric key for the authentication code.

## Return Value

A Boolean value that’s `true` if the message authentication
code is valid for the specified block of data.

---

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)