# Base16

**Base16**, also known as **hexadecimal encoding**, is a binary-to-text encoding scheme that represents binary data as a sequence of 16 characters (**0-9** and **A-F**).

## How it works ?

Hexadecimal encoding works by dividing the binary data into 4-bit blocks and then representing each block as a character in a predefined set of 16 characters.

This results in a representation that is more compact than the original binary data, making it easier to store or transmit.

To encode binary data as Base16, each group of 4 bits is converted to its corresponding hexadecimal character, and the characters are concatenated to form the final encoded string.

To decode Base16-encoded data, the reverse process is performed, converting each hexadecimal character back into its corresponding 4-bit binary representation and concatenating the results.

## Python

```python
data = b"SomeData"

hexData = data.hex()

decoded = bytes.fromhex(hexData)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.ctfrecipes.com/cryptography/general-knowledge/encoding/data-encoding/base16.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
