# Verhoeff Checksum

# Verhoeff Checksum

This module includes functions for Verhoeff checksum calculation and validation.

## Summary

The functions in this module are available when `OPENTHREAD_CONFIG_VERHOEFF_CHECKSUM_ENABLE` is enabled.

| ### Functions ||
|---|---|
| `https://openthread.io/reference/group/api-verhoeff-checksum#group__api-verhoeff-checksum_1gada5e4f7124b6926b0db576e8bfa75e28(const char *aDecimalString, char *aChecksum)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Calculates the Verhoeff checksum for a given decimal string. |
| `https://openthread.io/reference/group/api-verhoeff-checksum#group__api-verhoeff-checksum_1gaf968523db5ba29ef340033e36ddf2de1(const char *aDecimalString)` | `https://openthread.io/reference/group/api-error#group__api-error_1gabaaa90aaa35da8f9d394a227a23a6a49` Validates the Verhoeff checksum for a given decimal string. |

| ### Macros ||
|---|---|
| `https://openthread.io/reference/group/api-verhoeff-checksum#group__api-verhoeff-checksum_1ga19d119c38990e48c4ecf0a49b1392372 128` | Specifies the maximum length of decimal string input in `otVerhoeffChecksum` functions. |

## Functions

### otVerhoeffChecksumCalculate

```
otError otVerhoeffChecksumCalculate(
  const char *aDecimalString,
  char *aChecksum
)
```
Calculates the Verhoeff checksum for a given decimal string.

Requires `OPENTHREAD_CONFIG_VERHOEFF_CHECKSUM_ENABLE`.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aDecimalString` | The string containing decimal digits. | | `[out] aChecksum` | Pointer to a `char` to return the calculated checksum. | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully calculated the checksum, `aChecksum` is updated. | | `OT_ERROR_INVALID_ARGS` | The `aDecimalString` is not valid, i.e. it either contains chars other than \['0'-'9'\], or is longer than `OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH`. | |

### otVerhoeffChecksumValidate

```
otError otVerhoeffChecksumValidate(
  const char *aDecimalString
)
```
Validates the Verhoeff checksum for a given decimal string.

Requires `OPENTHREAD_CONFIG_VERHOEFF_CHECKSUM_ENABLE`.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `[in] aDecimalString` | The string containing decimal digits (last char is treated as checksum). | |
| Return Values | |---|---| | `OT_ERROR_NONE` | Successfully validated the checksum in `aDecimalString`. | | `OT_ERROR_FAILED` | Checksum validation failed. | | `OT_ERROR_INVALID_ARGS` | The `aDecimalString` is not valid, i.e. it either contains chars other than \['0'-'9'\], or is longer than `OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH`. | |

## Macros

### OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH

```
 OT_VERHOEFF_CHECKSUM_MAX_STRING_LENGTH 128
```
Specifies the maximum length of decimal string input in `otVerhoeffChecksum` functions.

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).