# Hex

## Description

> When we encrypt something the resulting ciphertext commonly has bytes which are not printable ASCII characters. If we want to share our encrypted data, it's common to encode it into something more user-friendly and portable across different systems.\
> \
> Hexadecimal can be used in such a way to represent ASCII strings. First each letter is converted to an ordinal number according to the ASCII table (as in the previous challenge). Then the decimal numbers are converted to base-16 numbers, otherwise known as hexadecimal. The numbers can be combined together, into one long hex string.\
> \
> Included below is a flag encoded as a hex string. Decode this back into bytes to get the flag.\
> \
> `63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d`\
> \
> &#x20;In Python, the `bytes.fromhex()` function can be used to convert hex to bytes. The `.hex()` instance method can be called on byte strings to get the hex representation.\
> \
> Resources:\
> &#x20; \- [ASCII table](https://www.rapidtables.com/code/text/ascii-table.html)\
> &#x20; \- [Wikipedia: Hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal)

## Reverse the Hex

We are given a string which is the flag we want, but it's been cursed by a horrible witch's hex!

Fortunately, we can brew a powerful antidote code

```python
HEX = "63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d"

# Convert the hex string into a byte string
flag = bytes.fromhex(HEX)

print(flag)
```

## Flag

`crypto{You_will_be_working_with_hex_strings_a_lot}`


---

# 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://soyabeanboi.gitbook.io/bag-of-flags/practice/cryptohack/general/hex.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.
