AUDIT\_ENCODE\_VALUE(3) Linux Audit API AUDIT\_ENCODE\_VALUE(3)

# [NAME](#NAME)

audit\_encode\_value - encode bytes as an ASCII hexadecimal string

# [SYNOPSIS](#SYNOPSIS)

```
#include <libaudit.h>
```

```
char *audit_encode_value(char *final, const char *buf, unsigned int size);
```

# [DESCRIPTION](#DESCRIPTION)

**audit\_encode\_value**() encodes *size* bytes from *buf* as an uppercase ASCII hexadecimal string. Each input byte is written as two hexadecimal digits. The input does not have to be NUL-terminated and may contain embedded NUL bytes.

*final* is the caller-provided output buffer. It must be at least *2 * size + 1* bytes long to hold the encoded value and its terminating NUL byte. *size* is the number of bytes to encode from *buf*, not necessarily the result of [**strlen**(3)](/man/os/audit/strlen.3).

If *buf* is NULL, **audit\_encode\_value**() writes an empty string to *final*.

e.g.: "foo bar" is encoded as "666F6F20626172". "\\1\\2\\3\\4" is encoded as "01020304".

# [RETURN VALUE](#RETURN_VALUE)

Returns *final* on success. If *final* is NULL, NULL is returned.

# [SEE ALSO](#SEE_ALSO)

[**audit\_encode\_nv\_string**(3)](/man/os/audit/audit_encode_nv_string.3), [**audit\_value\_needs\_encoding**(3)](/man/os/audit/audit_value_needs_encoding.3).

# [AUTHOR](#AUTHOR)

Steve Grubb

May 2026 Red Hat

---

Document: audit_encode_value(3) from audit 4.2.1-r1 (Chainguard OS)
Source: https://github.com/linux-audit/audit-userspace
