---
title: "isValidAuthenticationCode(_:authenticating:using:)"
framework: cryptokit
role: symbol
role_heading: Type Method
path: "cryptokit/hmac/isvalidauthenticationcode(_:authenticating:using:)-8ezmw"
---

# isValidAuthenticationCode(_:authenticating:using:)

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

## Declaration

```swift
static func isValidAuthenticationCode<D>(_ authenticationCode: HMAC<H>.MAC, authenticating authenticatedData: D, using key: SymmetricKey) -> Bool where 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

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

## See Also

### Checking an authentication code

- [isValidAuthenticationCode(_:authenticating:using:)](cryptokit/hmac/isvalidauthenticationcode(_:authenticating:using:)-5jbc8.md)
- [isValidAuthenticationCode(_:authenticating:using:)](cryptokit/hmac/isvalidauthenticationcode(_:authenticating:using:)-5ilt9.md)
