> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/conversions/decimal-numbers.md).

# Decimal numbers

## Convert in Bash

### Convert decimal numbers to ASCII

```bash
NUMS=$(echo "84, 104, 101, 32, 115, 111, 108, 117, 116, 105, 111, 110, 32, 105, 115, 58, 32, 111, 110, 100, 98, 105, 102, 103, 104, 115, 110, 110, 99" | tr -d ',') 
for num in $NUMS; do printf "\x$(printf %x "$num")"; done
```

Note that you cannot use this syntax in `zsh`!

## Convert in Python

### Convert decimal numbers to ASCII

```python
#!/usr/bin/python

enc = [84, 104, 101, 32, 115, 111, 108, 117, 116, 105, 111, 110, 32, 105, 115, 58, 32, 111, 110, 100, 98, 105, 102, 103, 104, 115, 110, 110, 99]

char_array = map(lambda num: chr(num), enc)
print(''.join(char_array))
```

## Convert with online services

You can also convert decimal numbers to ASCII with one of these online services:

CyberChef: <https://gchq.github.io/CyberChef/#recipe=From_Decimal('Space',false)>

RapidTables: <https://www.rapidtables.com/convert/number/ascii-hex-bin-dec-converter.html>

## Resources

Decimal - Wikipedia: <https://en.wikipedia.org/wiki/Decimal>
